123456789_123456789_123456789_123456789_123456789_

Class: Layout::SketchUpModel

Relationships
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Entity
Instance Chain:
self, Entity
Inherits: Layout::Entity

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

Class Method Summary

Instance Attribute Summary

Entity - Inherited

#locked=

The #locked= method sets the Entity as locked or unlocked.

#locked?

The #locked? method returns whether the Entity is locked or unlocked.

#on_shared_layer?

The #on_shared_layer? method returns whether or not the Entity is on a shared Layer.

#style

The #style method returns the Style of the Entity.

#style=

The #style= method sets the Style of the Entity.

#untransformed_bounds

The #untransformed_bounds method returns the untransformed bounds of the Entity.

#untransformed_bounds=

The #untransformed_bounds= method sets the untransformed bounds of the Entity.

Instance Method Summary

Entity - Inherited

#==

The #== method checks to see if the two Entitys are equal.

#bounds

The #bounds method returns the 2D rectangular bounds of the Entity.

#document

The #document method returns the Document that the Entity belongs to, or nil if it is not in a Document.

#drawing_bounds

The #drawing_bounds method returns the 2D rectangular drawing bounds of the Entity.

#group

The #group method returns the Group the Entity belongs to, or nil if it is not in a Group.

#layer_instance

The #layer_instance method returns the LayerInstance that the Entity is on, or nil if it is not associated with a LayerInstance.

#move_to_group

The #move_to_group method moves the Entity into a Group.

#move_to_layer

The #move_to_layer method moves the Entity to the given Layer.

#page

The #page method returns the Page that the Entity belongs to, or nil if it is on a shared Layer or not in a Document.

#transform!

The #transform! method transforms the Entity with a given ::Geom::Transformation2d.

#transformation

The #transformation method returns the explicit ::Geom::Transformation2d.

Constructor Details

.new(path, bounds) ⇒ SketchUpModel

The #initialize method creates a new 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 Attribute Details

#camera_modified?Boolean (readonly)

The #camera_modified? method returns whether the camera of the 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?

Version:

  • LayOut 2020.1

#clip_maskLayout::Entity (rw)

The #clip_mask method returns the clip mask entity for the 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

Version:

  • LayOut 2018

#clip_mask=(clip_mask) (rw)

Note:

clip_mask may be nil as of LayOut 2020.1.

The #clip_mask= method sets a clip mask for the 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 (rw)

The #current_scene method returns the index of the most recently selected scene of the 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

Raises:

  • (ArgumentError)

    if the most recently selected scene no longer exists

Version:

  • LayOut 2018

#current_scene=(index) (rw)

Note:

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

The #current_scene= method sets the scene of the 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 (readonly)

The #current_scene_modified? method returns whether the most recently selected scene of the 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?

Raises:

  • (ArgumentError)

    if the most recently selected scene no longer exists

Version:

  • LayOut 2018

#dash_scaleFloat (rw)

The #dash_scale method returns the dash scale for the 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

Version:

  • LayOut 2019

#dash_scale=(dash_scale) (rw)

The #dash_scale= method sets the dash scale for the 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) (rw)

The #display_background= method sets whether the background is displayed for the 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 (rw)

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

Examples:

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

Version:

  • LayOut 2018

#effects_modified?Boolean (readonly)

The #effects_modified? method returns whether the shadow or fog settings of the 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?

Version:

  • LayOut 2020.1

#layers_modified?Boolean (readonly)

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”.

The #layers_modified? method returns whether the layers of the 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.layers_modified?

Version:

  • LayOut 2020.1

#line_weightFloat (rw)

The #line_weight method returns the line weight for the 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

Version:

  • LayOut 2018

#line_weight=(line_weight) (rw)

The #line_weight= method sets the line weight for the 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

#perspective=(perspective) (rw)

The #perspective= method sets whether the 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 (rw)

The #perspective? method returns whether the 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?

Version:

  • LayOut 2018

#preserve_scale_on_resize=(preserve_scale) (rw)

The #preserve_scale_on_resize= method sets whether the scale is preserved when the 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 (rw)

The #preserve_scale_on_resize? method returns whether the scale is preserved when the 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?

Version:

  • LayOut 2018

#render_modeInteger (rw)

The #render_mode method returns the render mode of the 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

Version:

  • LayOut 2018

#render_mode=(render_mode) (rw)

The #render_mode= method sets the render mode of the 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 (readonly)

The #render_needed? method returns whether the 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?

Version:

  • LayOut 2018

#scaleFloat (rw)

The #scale method returns the scale of the SketchUpModel.

Examples:

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

Version:

  • LayOut 2018

#scale=(scale) (rw)

The #scale= method sets the scale of the 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:

  • (ArgumentError)

    if the SketchUpModel view is not orthographic

  • (ArgumentError)

    if scale is less than 0.0000001

  • (LockedLayerError)

    if the SketchUpModel is on a locked Layer

  • (LockedEntityError)

    if the SketchUpModel is locked

Version:

  • LayOut 2018

#style_modified?Boolean (readonly)

The #style_modified? method returns whether the style of the 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?

Version:

  • LayOut 2020.1

#viewInteger (rw)

The #view method returns the standard view of the 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

Version:

  • LayOut 2018

#view=(view) (rw)

The #view= method sets the standard view of the 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

Instance Method Details

#entitiesLayout::Entity

The #entities method returns the Group that represents the 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

Version:

  • LayOut 2018

#model_to_paper_point(model_point) ⇒ Geom::Point2d

The #model_to_paper_point method converts the ::Geom::Point3d in the 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:

Version:

  • LayOut 2018

#output_entitiesLayout::Entity

The #output_entities method returns the Group that represents the SketchUpModel in its exported 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. This takes into account the output resolution set in the document’s PageInfo, and the render mode override set on the document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
bounds = Geom::Bounds2d.new(1, 1, 3, 3)
model = Layout::SketchUpModel.new("C:/Path/to/model.skp", bounds)
doc.add_entity(model, doc.layers.first, doc.pages.first)
doc.render_mode_override = Layout::SketchUpModel::HYBRID_RENDER
entities = model.output_entities

Version:

  • LayOut 2023.1

#render

The #render method renders the 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

#reset_camera

The #reset_camera method resets the 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_effects

The #reset_effects method resets the 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_layers

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”.

The #reset_layers method resets the SketchUpModel‘s layers 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_layers if model.layers_modified?

Raises:

Version:

  • LayOut 2020.1

#reset_style

The #reset_style method resets the 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

#scenesArray<String>

The #scenes method returns an array of scene names that are available for the 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

Version:

  • LayOut 2018