Class: Layout::SketchUpModel
- Inherits:
-
Layout::Entity
- Object
- Layout::Entity
- Layout::SketchUpModel
Overview
Model Viewport: Displays a scene, or a single component or group (independent viewport). Parallel projection viewports have a fixed scale and can project model points, associated dimensions, sections, and details. When the drawing workspace is open, new and modified viewports are automatically plotted in the background.
Constants # collapse
- Layout::SketchUpModel::RASTER_RENDER
Render Style: Bitmap.
- Layout::SketchUpModel::HYBRID_RENDER
Render Mode: Hybrid (vector lines on a colored background).
- Layout::SketchUpModel::VECTOR_RENDER
Render Style: Line Drawing (Black and White Vector).
- Layout::SketchUpModel::CUSTOM_VIEW
Custom camera (not a standard view).
- Layout::SketchUpModel::TOP_VIEW
Standard View: Top View.
- Layout::SketchUpModel::TOP_RELATIVE_VIEW
The relative top view in LayOut.
- Layout::SketchUpModel::BOTTOM_VIEW
Standard View: Bottom View.
- Layout::SketchUpModel::BOTTOM_RELATIVE_VIEW
The LayOut relative bottom view.
- Layout::SketchUpModel::FRONT_VIEW
Standard View: Front View.
- Layout::SketchUpModel::BACK_VIEW
Standard View: Back View.
- Layout::SketchUpModel::LEFT_VIEW
Standard View: Left View.
- Layout::SketchUpModel::RIGHT_VIEW
Standard View: Right View.
- Layout::SketchUpModel::ISO_VIEW
Standard View: Isometric.
Class Method Summary # collapse
-
.new(scene, bounds) ⇒ Layout::SketchUpModel
Create a viewport and then add it to the drawing sheet using Layout::Document#add_entity. The scene viewport displays the scene's camera, style, and hidden elements. An instance viewport (independent viewport) only shows the component or group instance, defaulting to a top view with parallel projection, and uses integer scaling ratios. Nested instances are specified with ModraUp::InstancePath.
Instance Method Summary # collapse
-
#scale ⇒ Float, nil
The scale is a ratio (e.g., 1:50 corresponds to 0.02). The instance viewport in the layout has not been documented and is nil if the scale is not applied (the scale is calculated based on size when applied).
-
#scale= ⇒ Numeric
Set the scale, one step undo. The camera height for parallel projection is derived from "viewport height × scale denominator".
- #render_mode ⇒ Integer
-
#render_mode= ⇒ Integer
Set the rendering mode, with one-step undo. Wireframe is black and white; switch to colored background when mixed in black and white.
-
#view ⇒ Integer
Standard views (e.g., TOP_VIEW);custom camera as CUSTOM_VIEW.
-
#view= ⇒ Integer
Switch to the standard view, undo one step. The scale remains unchanged in parallel projection.
-
#perspective? ⇒ Boolean
Returns whether the projection is perspective.
-
#perspective= ⇒ Boolean
Switch between perspective or parallel projection, with one step undo. When switching to parallel projection, the ratio is calculated based on the current viewport.
-
#line_weight ⇒ Float
Model line weight in points; 0 for automatic.
-
#line_weight= ⇒ Numeric
Sets the model line weight, undoable in one step.
-
#scenes ⇒ Array<String>
The model's scene names, in the order of ModraUp::Pages.
-
#current_scene ⇒ Integer, nil
The index of the displayed scene in #scenes; nil if the instance viewport or scene has been deleted.
-
#current_scene= ⇒ Integer, ModraUp::Page
Change to display another scene, undo one step; camera returns to the camera of that scene.
-
#camera_modified? ⇒ Boolean
The camera is different from the scene (true after the standard view, navigation, or #camera=; instance viewports always return true).
-
#reset_camera ⇒ Layout::SketchUpModel
Reset the camera to the scene's initial view, one step undo.
-
#preserve_scale_on_resize? ⇒ Boolean
Does the viewport maintain scale when its size is changed (default is true).
-
#preserve_scale_on_resize= ⇒ Boolean
Sets whether to preserve scale on resizing, with one step for undo.
-
#render_needed? ⇒ Boolean
Does the preview need to be updated (not the latest, not generated, model has changed, or updating)? The drawing workspace updates in the background automatically when open.
-
#render ⇒ Object
Does not support synchronous rendering: rendering occurs in a separate process, and the results are returned via the interface event loop.
-
#model_to_paper_point(point) ⇒ Geom::Point2d
The position of a model point on the paper in inches, including viewport translation, rotation, and scale.
-
#paper_to_model_point(point) ⇒ Geom::Point3d
The paper point corresponding to the model point, lying on the plane that passes through the camera's target and is perpendicular to the camera's view.
-
#camera ⇒ ModraUp::Camera
The camera copy actually used by the viewport (scene camera or custom camera).
-
#camera= ⇒ ModraUp::Camera
Set custom camera, with one-step undo. For parallel projection, the scale is inferred from the camera height.
-
#source ⇒ ModraUp::Page, ModraUp::InstancePath, nil
The source of the viewport: the scene, or the instance path of an independent viewport; it becomes nil when the source is deleted.
-
#color_mode ⇒ Symbol
Color: black_and_white, color, or grayscale.
-
#color_mode= ⇒ Symbol
Set the color mode, undoing any changes. After selecting color or grayscale in the sketch viewport, the model switches to mixed representation.
-
#pan ⇒ Array<Length>
Pan the viewport by [x, y] (in paper inches).
-
#pan= ⇒ Array
Set the viewport pan, one step in the undo.
-
#create_section(first, second, look, depth: nil, position: nil, page: nil) ⇒ Layout::SketchUpModel
Generate a section view from the current viewport, with one undo step, resulting in the same outcome as the section tool: a new viewport with section numbers, and the original viewport with a section cut symbol. The points first and second are the model points at the ends of the section line, which should project as a line in the current viewport (at least 0.1 mm long); the section plane contains this line and the viewing direction of the current viewport. The look parameter specifies the viewing direction of the section, pointing to the retained side.
-
#create_detail(corner1, corner2, scale: nil, position:, page: nil) ⇒ Layout::SketchUpModel
Generate a detail drawing from this viewport, with one undo step, similar to the detail tool: create a region bounded by two model points in the current viewport and scale it to a larger proportion at position, adding the detail frame to the current viewport.
-
#section_marks ⇒ Array<Hash>
Section marks in the current viewport: each {first:, second:, normal:, target:}, where target is the section plane (set to nil if removed).
-
#visible_lines(kinds: [:model]) ⇒ Array<Layout::VisibleLine>
Hidden visible edges in the sketch plane, in inches, used for outlining, generating continuous dimensions, etc. Prioritizes reusing exported and snap-captured vector caches;
Inherited from Layout::Entity
-
#bounds ⇒ Geom::Bounds2d
The bounding box after rotation, in paper inches.
-
#untransformed_bounds ⇒ Geom::Bounds2d
Unrotated bounds (x, y, width, height), paper inches.
-
#untransformed_bounds= ⇒ Geom::Bounds2d
Modify position and size, with one undo step. The rules are the same as for the layout: the view preserves scale on resize (default) when Layout::SketchUpModel#preserve_scale_on_resize? is true, otherwise it scales by height only; dimensions and leaders only move and do not scale. If they extend beyond the paper edge, they are clipped back within the paper.
-
#style ⇒ Layout::Style
A copy of the current style. Modifying the copy does not affect the object; use #style= to apply the changes.
-
#style= ⇒ Layout::Style
Apply the style, undoing one step. Only apply properties relevant to the object type (e.g., text ignoring line type).
-
#page ⇒ Layout::Page, nil
The current page; objects on shared layers or those not yet added to the document are nil.
-
#document ⇒ Layout::Document, nil
Belongs to a Layout::Entity document; is nil if not added yet.
-
#on_shared_layer? ⇒ Boolean
Returns true if the entity is on a shared layer.
-
#layer_instance ⇒ Layout::LayerInstance, nil
The layer it resides on; nil if not added yet.
-
#move_to_layer(layer, pages = nil) ⇒ Layout::Entity
Move to another layer, one undo step. Objects on a shared layer remain on their associated page when moved to a regular layer.
-
#rotation ⇒ Float
Rotation angle around the bounding box center (degrees).
-
#rotation= ⇒ Numeric
Rotate around the bounding box center, one step in undo. Dimensions and leaders do not accept rotation (they follow their endpoints).
-
#get_attribute(dictionary, key, default = nil) ⇒ Object
Read plugin data on the object. Plugins can use this to identify objects they generate, such as re-creating automatic leader and dimension annotations.
-
#set_attribute(dictionary, key, value) ⇒ Object
Save plugin data on the object with a single undo step. Values can only be types that JSON can represent (nil, true, false, numbers, strings, Array, Hash), and a single object should not exceed 64 KB.
-
#delete_attribute(dictionary) ⇒ Boolean
Delete a key or an entire dictionary.
-
#attribute_dictionary(name, create = false) ⇒ Hash, nil
A copy of a dictionary.
-
#locked? ⇒ Object
Unsupported: OpenSu does not support object-level locking (please lock the layer).
-
#locked= ⇒ Object
Unsupported: OpenSu does not support object-level locking (please lock the layer).
-
#transform!(transformation) ⇒ Object
Unsupported: OpenSu does not support Geom::Transformation2d. For translation, use #untransformed_bounds=, and for rotation, use #rotation=.
-
#group ⇒ Object
Does not support: OpenSu drawings cannot be grouped.
-
#== ⇒ Boolean
Returns whether the two references identify the same drawing entity.
-
#eql?(other) ⇒ Boolean
Like #==, used as a key in a Hash.
-
#hash ⇒ Integer
Hash value consistent with #eql?.
-
#inspect ⇒ String
A brief description.
Class Method Details
Layout::SketchUpModel.new(scene, bounds) ⇒ Layout::SketchUpModelLayout::SketchUpModel.new(instance, bounds) ⇒ Layout::SketchUpModelLayout::SketchUpModel.new(instance_path, bounds) ⇒ Layout::SketchUpModel
Create a viewport and then add it to the drawing sheet using Layout::Document#add_entity. The scene viewport displays the scene's camera, style, and hidden elements. An instance viewport (independent viewport) only shows the component or group instance, defaulting to a top view with parallel projection, and uses integer scaling ratios. Nested instances are specified with ModraUp::InstancePath.
Instance Method Details
viewport.scale ⇒ Float, nil
The scale is a ratio (e.g., 1:50 corresponds to 0.02). The instance viewport in the layout has not been documented and is nil if the scale is not applied (the scale is calculated based on size when applied).
viewport.scale = ratio
Set the scale, one step undo. The camera height for parallel projection is derived from "viewport height × scale denominator".
viewport.render_mode ⇒ Integer
Render mode: VECTOR_RENDER, HYBRID_RENDER, or RASTER_RENDER.
viewport.render_mode = mode
Set the rendering mode, with one-step undo. Wireframe is black and white; switch to colored background when mixed in black and white.
viewport.view ⇒ Integer
Standard views (e.g., TOP_VIEW);custom camera as CUSTOM_VIEW.
viewport.view = view
Switch to the standard view, undo one step. The scale remains unchanged in parallel projection.
viewport.perspective? ⇒ Boolean
Returns whether the projection is perspective.
viewport.perspective = perspective
Switch between perspective or parallel projection, with one step undo. When switching to parallel projection, the ratio is calculated based on the current viewport.
viewport.line_weight ⇒ Float
Model line weight in points; 0 for automatic.
viewport.line_weight = points
Sets the model line weight, undoable in one step.
viewport.scenes ⇒ Array<String>
The model's scene names, in the order of ModraUp::Pages.
viewport.current_scene ⇒ Integer, nil
The index of the displayed scene in #scenes; nil if the instance viewport or scene has been deleted.
viewport.current_scene = scene
Change to display another scene, undo one step; camera returns to the camera of that scene.
viewport.camera_modified? ⇒ Boolean
The camera is different from the scene (true after the standard view, navigation, or #camera=; instance viewports always return true).
viewport.reset_camera ⇒ Layout::SketchUpModel
Reset the camera to the scene's initial view, one step undo.
viewport.preserve_scale_on_resize? ⇒ Boolean
Does the viewport maintain scale when its size is changed (default is true).
viewport.preserve_scale_on_resize = keep
Sets whether to preserve scale on resizing, with one step for undo.
viewport.render_needed? ⇒ Boolean
Does the preview need to be updated (not the latest, not generated, model has changed, or updating)? The drawing workspace updates in the background automatically when open.
viewport.render ⇒ raises
Does not support synchronous rendering: rendering occurs in a separate process, and the results are returned via the interface event loop.
viewport.model_to_paper_point(point) ⇒ Geom::Point2d
The position of a model point on the paper in inches, including viewport translation, rotation, and scale.
viewport.paper_to_model_point(point) ⇒ Geom::Point3d
The paper point corresponding to the model point, lying on the plane that passes through the camera's target and is perpendicular to the camera's view.
viewport.camera ⇒ ModraUp::Camera
The camera copy actually used by the viewport (scene camera or custom camera).
viewport.camera = camera
Set custom camera, with one-step undo. For parallel projection, the scale is inferred from the camera height.
viewport.source ⇒ ModraUp::Page, ModraUp::InstancePath, nil
The source of the viewport: the scene, or the instance path of an independent viewport; it becomes nil when the source is deleted.
viewport.color_mode ⇒ Symbol
Color: black_and_white, color, or grayscale.
viewport.color_mode = mode
Set the color mode, undoing any changes. After selecting color or grayscale in the sketch viewport, the model switches to mixed representation.
viewport.pan ⇒ Array<Length>
Pan the viewport by [x, y] (in paper inches).
viewport.pan = [x, y]
Set the viewport pan, one step in the undo.
viewport.create_section(first, second, look, depth: nil, position: nil, page: nil) ⇒ Layout::SketchUpModel
Generate a section view from the current viewport, with one undo step, resulting in the same outcome as the section tool: a new viewport with section numbers, and the original viewport with a section cut symbol. The points first and second are the model points at the ends of the section line, which should project as a line in the current viewport (at least 0.1 mm long); the section plane contains this line and the viewing direction of the current viewport. The look parameter specifies the viewing direction of the section, pointing to the retained side.
If position is not provided, the tool will arrange the section views according to its rules: first try right, left, down, and up, then move the original viewport overall, and if it still cannot fit, create a new sheet of the same size.
viewport.create_detail(corner1, corner2, scale: nil, position:, page: nil) ⇒ Layout::SketchUpModel
Generate a detail drawing from this viewport, with one undo step, similar to the detail tool: create a region bounded by two model points in the current viewport and scale it to a larger proportion at position, adding the detail frame to the current viewport.
viewport.section_marks ⇒ Array<Hash>
Section marks in the current viewport: each {first:, second:, normal:, target:}, where target is the section plane (set to nil if removed).
viewport.visible_lines(kinds: [:model]) ⇒ Array<Layout::VisibleLine>
Hidden visible edges in the sketch plane, in inches, used for outlining, generating continuous dimensions, etc. Prioritizes reusing exported and snap-captured vector caches; if not found, it is computed synchronously on the main thread, causing a brief interface unresponsiveness, with duration increasing with model size; plugins should call this only for necessary views.