Class: Layout::SketchUpModel

Inherits:
Entity
  • Object
show all

Overview

A SketchUp Model entity. This is an instance of a SketchUp Model that is inserted into a .layout file. You can change the render mode, line weight, and set the current scene for the SketchUp Model with this interface.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
model.current_scene = 2
model.view = Layout::SketchUpModel::FRONT_VIEW
model.render_mode = Layout::SketchUpModel::VECTOR_RENDER
model.render if model.render_needed?

Version:

  • LayOut 2018

Constant Summary #

Layout::SketchUpModel::RASTER_RENDER
Layout::SketchUpModel::HYBRID_RENDER
Layout::SketchUpModel::VECTOR_RENDER
Layout::SketchUpModel::CUSTOM_VIEW
Layout::SketchUpModel::TOP_VIEW
Layout::SketchUpModel::TOP_RELATIVE_VIEW
Layout::SketchUpModel::BOTTOM_VIEW
Layout::SketchUpModel::BOTTOM_RELATIVE_VIEW
Layout::SketchUpModel::FRONT_VIEW
Layout::SketchUpModel::BACK_VIEW
Layout::SketchUpModel::LEFT_VIEW
Layout::SketchUpModel::RIGHT_VIEW
Layout::SketchUpModel::ISO_VIEW

Instance Method Summary # collapse

Methods inherited from Entity

#==, #bounds, #document, #drawing_bounds, #group, #layer_instance, #locked=, #locked?, #move_to_group, #move_to_layer, #on_shared_layer?, #page, #style, #style=, #transform!, #transformation, #untransformed_bounds, #untransformed_bounds=

Constructor Details

#initialize(path, bounds) ⇒ Layout::SketchUpModel

The #initialize method creates a new Layout::SketchUpModel.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)

Parameters:

Raises:

  • (ArgumentError)

    if path does not point to a valid SketchUp Model file

  • (ArgumentError)

    if bounds is zero size

Version:

  • LayOut 2018

Instance Method Details

#camera_modified?Boolean

The #camera_modified? method returns whether the camera of the Layout::SketchUpModel has been modified.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
modified = model.camera_modified?

Returns:

  • (Boolean)

Version:

  • LayOut 2020.1

#clip_maskLayout::Entity

The #clip_mask method returns the clip mask entity for the Layout::SketchUpModel, or nil if it does not have one. clip_mask can be a Rectangle, Ellipse, or Path.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
clip_mask = model.clip_mask

Returns:

Version:

  • LayOut 2018

#clip_mask=(clip_mask) ⇒ Object

Note:

clip_mask may be nil as of LayOut 2020.1.

The #clip_mask= method sets a clip mask for the Layout::SketchUpModel. clip_mask can be a Rectangle, Ellipse, or Path, or nil, and it must not currently exist in a Document, or Group.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
rect = Layout::Rectangle.new([[2, 2], [3, 3]]);
model.clip_mask = rect

Parameters:

Raises:

Version:

  • LayOut 2018

#current_sceneInteger

The #current_scene method returns the index of the most recently selected scene of the Layout::SketchUpModel.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
scene_index = model.current_scene

Returns:

  • (Integer)

Raises:

  • (ArgumentError)

    if the most recently selected scene no longer exists

Version:

  • LayOut 2018

#current_scene=(index) ⇒ Object

Note:

LayOut automatically adds the scene “Last Saved SketchUp View” to each Layout::SketchUpModel. This means that the Sketchup::Model's scenes start with index 1.

The #current_scene= method sets the scene of the Layout::SketchUpModel.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
model.current_scene = 1

Parameters:

  • index (Integer)

    The index into the list of available scenes.

Raises:

Version:

  • LayOut 2018

#current_scene_modified?Boolean

The #current_scene_modified? method returns whether the most recently selected scene of the Layout::SketchUpModel has been modified.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
modified = model.current_scene_modified?

Returns:

  • (Boolean)

Raises:

  • (ArgumentError)

    if the most recently selected scene no longer exists

Version:

  • LayOut 2018

#dash_scaleFloat

The #dash_scale method returns the dash scale for the Layout::SketchUpModel. A scale value of 0.0 means the dashes are scaled based on the line weight.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
dash_scale = model.dash_scale

Returns:

  • (Float)

Version:

  • LayOut 2019

#dash_scale=(dash_scale) ⇒ Object

The #dash_scale= method sets the dash scale for the Layout::SketchUpModel. A scale value of 0.0 or lower will “auto” scale the dashes based on the line weight.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
model.dash_scale = 2.5

Parameters:

  • dash_scale (Float)

Raises:

Version:

  • LayOut 2018

#display_background=(display) ⇒ Object

The #display_background= method sets whether the background is displayed for the Layout::SketchUpModel.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
model.display_background = false

Parameters:

  • display (Boolean)

Raises:

Version:

  • LayOut 2018

#display_background?Boolean

The #display_background? method returns whether the background is displayed for the Layout::SketchUpModel.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
displayed = model.display_background?

Returns:

  • (Boolean)

Version:

  • LayOut 2018

#effects_modified?Boolean

The #effects_modified? method returns whether the shadow or fog settings of the Layout::SketchUpModel have been modified.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
modified = model.effects_modified?

Returns:

  • (Boolean)

Version:

  • LayOut 2020.1

#entitiesLayout::Entity

The #entities method returns the Group that represents the Layout::SketchUpModel in its exploded form. The Group will contain a Image for raster and hybrid-rendered models, and will contain a Group of LayOut entities for vector and hybrid-rendered models.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
entities = model.entities

Returns:

Version:

  • LayOut 2018

#layers_modified?Boolean

The #layers_modified? method returns whether the layers of the Layout::SketchUpModel has been modified.

@note: In SketchUp 2020, SketchUp “layers” were renamed to “tags”. For

consistency with the SketchUp API, this will continue to refer to
"tags" as "layers".

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
modified = model.layers_modified?

Returns:

  • (Boolean)

Version:

  • LayOut 2020.1

#line_weightFloat

The #line_weight method returns the line weight for the Layout::SketchUpModel.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
line_weight = model.line_weight

Returns:

  • (Float)

Version:

  • LayOut 2018

#line_weight=(line_weight) ⇒ Object

The #line_weight= method sets the line weight for the Layout::SketchUpModel. Line weight must be at least 0.01.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
model.line_weight = 2.5

Parameters:

  • line_weight (Float)

Raises:

Version:

  • LayOut 2018

#model_to_paper_point(model_point) ⇒ Geom::Point2d

The #model_to_paper_point method converts the Geom::Point3d in the Layout::SketchUpModel to a Geom::Point2d in paper space.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
point_3d = [200, 100, 100]
point_2d = model.model_to_paper_point(point_3d)

Parameters:

Returns:

Version:

  • LayOut 2018

#perspective=(perspective) ⇒ Object

The #perspective= method sets whether the Layout::SketchUpModel's view is perspective or orthographic.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
model.perspective = false

Parameters:

  • perspective (Boolean)

Raises:

Version:

  • LayOut 2018

#perspective?Boolean

The #perspective? method returns whether the Layout::SketchUpModel's view is perspective or orthographic.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
perspective = model.perspective?

Returns:

  • (Boolean)

Version:

  • LayOut 2018

#preserve_scale_on_resize=(preserve_scale) ⇒ Object

The #preserve_scale_on_resize= method sets whether the scale is preserved when the Layout::SketchUpModel is resized.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
model.preserve_scale_on_resize = true

Parameters:

  • preserve_scale (Boolean)

Raises:

Version:

  • LayOut 2018

#preserve_scale_on_resize?Boolean

The #preserve_scale_on_resize? method returns whether the scale is preserved when the Layout::SketchUpModel is resized.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
will_scale = model.preserve_scale_on_resize?

Returns:

  • (Boolean)

Version:

  • LayOut 2018

#renderObject

The #render method renders the Layout::SketchUpModel. If the model belongs to a Document, then the render will be performed at the quality set in document.page_info (see Document and PageInfo). Otherwise, the render will be performed at Low quality.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
model.render if model.render_needed?

Raises:

Version:

  • LayOut 2018

#render_modeInteger

The #render_mode method returns the render mode of the Layout::SketchUpModel.

The render mode can be one of the following:

Layout::SketchUpModel::RASTER_RENDER
Layout::SketchUpModel::HYBRID_RENDER
Layout::SketchUpModel::VECTOR_RENDER

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
render_mode = model.render_mode

Returns:

  • (Integer)

Version:

  • LayOut 2018

#render_mode=(render_mode) ⇒ Object

The #render_mode= method sets the render mode of the Layout::SketchUpModel.

The render mode can be one of the following:

Layout::SketchUpModel::RASTER_RENDER
Layout::SketchUpModel::HYBRID_RENDER
Layout::SketchUpModel::VECTOR_RENDER

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
model.render_mode = Layout::SketchUpModel::RASTER_RENDER

Parameters:

  • render_mode (Integer)

Raises:

Version:

  • LayOut 2018

#render_needed?Boolean

The #render_needed? method returns whether the Layout::SketchUpModel needs to be rendered.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
model.render if model.render_needed?

Returns:

  • (Boolean)

Version:

  • LayOut 2018

#reset_cameraObject

The #reset_camera method resets the Layout::SketchUpModel's camera to the scene's setting.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
model.reset_camera if model.camera_modified?

Raises:

Version:

  • LayOut 2020.1

#reset_effectsObject

The #reset_effects method resets the Layout::SketchUpModel's shadow and fog settings to the scene's settings.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
model.reset_effects if model.effects_modified?

Raises:

Version:

  • LayOut 2020.1

#reset_layersObject

The #reset_layers method resets the Layout::SketchUpModel's layers to the scene's setting.

@note: In SketchUp 2020, SketchUp “layers” were renamed to “tags”. For

consistency with the SketchUp API, this will continue to refer to
"tags" as "layers".

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
model.reset_layers if model.layers_modified?

Raises:

Version:

  • LayOut 2020.1

#reset_styleObject

The #reset_style method resets the Layout::SketchUpModel's style to the scene's setting.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
model.reset_style if model.style_modified?

Raises:

Version:

  • LayOut 2020.1

#scaleFloat

The #scale method returns the scale of the Layout::SketchUpModel.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
scale = model.scale

Returns:

  • (Float)

Version:

  • LayOut 2018

#scale=(scale) ⇒ Object

The #scale= method sets the scale of the Layout::SketchUpModel. Scale must be at least 0.0000001, and the view must be orthographic.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
model.scale = 2.0

Parameters:

  • scale (Float)

Raises:

Version:

  • LayOut 2018

#scenesArray<String>

The #scenes method returns an array of scene names that are available for the Layout::SketchUpModel. The first scene will always be the default scene, called “Last saved SketchUp View”.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
scene_names = model.scenes

Returns:

Version:

  • LayOut 2018

#style_modified?Boolean

The #style_modified? method returns whether the style of the Layout::SketchUpModel has been modified.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
modified = model.style_modified?

Returns:

  • (Boolean)

Version:

  • LayOut 2020.1

#viewInteger

The #view method returns the standard view of the Layout::SketchUpModel.

The standard view can be one of the following values:

Layout::SketchUpModel::CUSTOM_VIEW
Layout::SketchUpModel::TOP_VIEW
Layout::SketchUpModel::TOP_RELATIVE_VIEW
Layout::SketchUpModel::BOTTOM_VIEW
Layout::SketchUpModel::BOTTOM_RELATIVE_VIEW
Layout::SketchUpModel::FRONT_VIEW
Layout::SketchUpModel::BACK_VIEW
Layout::SketchUpModel::LEFT_VIEW
Layout::SketchUpModel::RIGHT_VIEW
Layout::SketchUpModel::ISO_VIEW

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
view = model.view

Returns:

  • (Integer)

Version:

  • LayOut 2018

#view=(view) ⇒ Object

The #view= method sets the standard view of the Layout::SketchUpModel.

The standard view can be one of the following values:

Layout::SketchUpModel::TOP_VIEW
Layout::SketchUpModel::TOP_RELATIVE_VIEW
Layout::SketchUpModel::BOTTOM_VIEW
Layout::SketchUpModel::BOTTOM_RELATIVE_VIEW
Layout::SketchUpModel::FRONT_VIEW
Layout::SketchUpModel::BACK_VIEW
Layout::SketchUpModel::LEFT_VIEW
Layout::SketchUpModel::RIGHT_VIEW
Layout::SketchUpModel::ISO_VIEW

Examples:

bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
model.view = Layout::SketchUpModel::FRONT_VIEW

Parameters:

  • view (Integer)

Raises:

Version:

  • LayOut 2018