ModraUp Ruby API Documentation Ruby API Reference

Class: ModraUp::Model

Inherits:
Object
  • Object
show all

Overview

An open model document. Obtain it from ModraUp.active_model. Direct construction with Model.new is unsupported.

Examples:

model = ModraUp.active_model
model.start_operation("Face")
model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0])
model.commit_operation

Constants # collapse

ModraUp::Model::VERSION_3

The target format constants for #save and #save_copy. The current SKP writer only supports VERSION_2017.

Returns:

  • (Integer)

Examples:

ModraUp::Model::VERSION_3
ModraUp::Model::VERSION_4

See VERSION_3.

Returns:

  • (Integer)

Examples:

ModraUp::Model::VERSION_4
ModraUp::Model::VERSION_5

See VERSION_3.

Returns:

  • (Integer)

Examples:

ModraUp::Model::VERSION_5
ModraUp::Model::VERSION_6

See VERSION_3.

Returns:

  • (Integer)

Examples:

ModraUp::Model::VERSION_6
ModraUp::Model::VERSION_7

See VERSION_3.

Returns:

  • (Integer)

Examples:

ModraUp::Model::VERSION_7
ModraUp::Model::VERSION_8

See VERSION_3.

Returns:

  • (Integer)

Examples:

ModraUp::Model::VERSION_8
ModraUp::Model::VERSION_2013

See VERSION_3.

Returns:

  • (Integer)

Examples:

ModraUp::Model::VERSION_2013
ModraUp::Model::VERSION_2014

See VERSION_3.

Returns:

  • (Integer)

Examples:

ModraUp::Model::VERSION_2014
ModraUp::Model::VERSION_2015

See VERSION_3.

Returns:

  • (Integer)

Examples:

ModraUp::Model::VERSION_2015
ModraUp::Model::VERSION_2016

See VERSION_3.

Returns:

  • (Integer)

Examples:

ModraUp::Model::VERSION_2016
ModraUp::Model::VERSION_2017

See VERSION_3.

Returns:

  • (Integer)

Examples:

ModraUp::Model::VERSION_2017
ModraUp::Model::VERSION_2018

See VERSION_3.

Returns:

  • (Integer)

Examples:

ModraUp::Model::VERSION_2018
ModraUp::Model::VERSION_2019

See VERSION_3.

Returns:

  • (Integer)

Examples:

ModraUp::Model::VERSION_2019
ModraUp::Model::VERSION_2020

See VERSION_3.

Returns:

  • (Integer)

Examples:

ModraUp::Model::VERSION_2020
ModraUp::Model::VERSION_2021

See VERSION_3.

Returns:

  • (Integer)

Examples:

ModraUp::Model::VERSION_2021
ModraUp::Model::ProTrial

One of the values returned by #get_product_family.

Returns:

  • (Integer)

Examples:

ModraUp::Model::ProTrial
ModraUp::Model::ProLicensed

One possible return value of #get_product_family. Currently agrees with ModraUp.is_pro?.

Returns:

  • (Integer)

Examples:

ModraUp::Model::ProLicensed
ModraUp::Model::MakeTrial

One of the values returned by #get_product_family.

Returns:

  • (Integer)

Examples:

ModraUp::Model::MakeTrial
ModraUp::Model::Make

One of the values returned by #get_product_family.

Returns:

  • (Integer)

Examples:

ModraUp::Model::Make
ModraUp::Model::LOAD_STATUS_SUCCESS

Loading the model was successful. The current ModraUp.open_file does not return this status to Ruby.

Returns:

  • (Integer)

Examples:

ModraUp::Model::LOAD_STATUS_SUCCESS
ModraUp::Model::LOAD_STATUS_SUCCESS_MORE_RECENT

Opened a file that is more recent than the current program version. Currently not in use.

Returns:

  • (Integer)

Examples:

ModraUp::Model::LOAD_STATUS_SUCCESS_MORE_RECENT

Instance Method Summary # collapse

Instance Method Details

#hatch_patterns ⇒ ModraUp::HatchPatterns

Returns the collection of hatch patterns in the model.

Returns:

  • (ModraUp::HatchPatterns)

Examples:

hatch_patterns = ModraUp.active_model.hatch_patterns

model.entities ⇒ ModraUp::Entities

Root drawing context of the model.

Returns:

  • (ModraUp::Entities)

Examples:

ModraUp.active_model.entities.add_line([0, 0, 0], [1, 0, 0])

model.active_entities ⇒ ModraUp::Entities

The current editing context (different from #entities after grouping).

Returns:

  • (ModraUp::Entities)

Examples:

ModraUp.active_model.active_entities

model.active_view ⇒ ModraUp::View

Current viewport. Repeated calls return a new wrapper pointing to the same camera and overlay state within the same model.

Returns:

  • (ModraUp::View)

Examples:

view = ModraUp.active_model.active_view
view.invalidate

model.axes ⇒ ModraUp::Axes

The current drawing coordinate axis changes with the group or component being edited.

Returns:

  • (ModraUp::Axes)

model.active_path ⇒ Array, nil

The active path in the group or component. Returns nil when editing at the root context. Returns a copy, so modifying the array with pop will not exit the edit mode.

Returns:

  • (Array<ModraUp::Group, ModraUp::ComponentInstance>, nil)

Examples:

ModraUp.active_model.active_path  #=> nil

model.active_path=(path) ⇒ model

Open a group/component path for editing. nil or an empty array returns to the root context. The path must be a layer-by-layer sequence of live ModraUp::Group / ModraUp::ComponentInstance starting from the model root.

Parameters:

  • path (ModraUp::InstancePath, Array<ModraUp::Group, ModraUp::ComponentInstance>, nil)

Returns:

  • (ModraUp::Model)

Raises:

  • [ArgumentError] Invalid path, or the path instance or another instance defined by the same definition is locked.

Examples:

inst = ModraUp.active_model.entities.add_instance(
  ModraUp.active_model.definitions.add("Box"))
ModraUp.active_model.active_path = [inst]
ModraUp.active_model.active_path = nil

model.close_active ⇒ Boolean

Exit the currently active group/component layer. Returns false if already at the root context.

Returns:

  • (Boolean)

Examples:

ModraUp.active_model.close_active

model.close(ignore_changes = false) ⇒ nil

Close the document tab containing the model (not necessarily the current document). If ignore_changes is false and the model has unsaved modifications, prompt to save; canceling keeps the document open. Closing the last document creates a new host document based on a template. After closing, the old Model and its entity objects are no longer accessible. Closing the current model without a host is equivalent to File > New.

Parameters:

  • ignore_changes [Boolean] when true, discards unsaved changes directly

Returns:

  • (nil)

Examples:

model = ModraUp.open_file(path) && ModraUp.active_model
model.close(true)

model.selection ⇒ ModraUp::Selection

Current selection set. Repeatedly calling it on the same model returns the same wrapper object.

Returns:

  • (ModraUp::Selection)

Examples:

ModraUp.active_model.selection.clear

model.tools ⇒ ModraUp::Tools

The tool manager for the current model.

Returns:

  • (ModraUp::Tools)

Examples:

ModraUp.active_model.tools.add_observer(ModraUp::ToolsObserver.new)

model.select_tool(tool = nil) ⇒ model

Activates a custom Ruby tool; nil returns to the select tool. Protocol follows ModraUp::Tool: any object that implements event methods, without needing to inherit. It will call activate, deactivate(view), and onSetCursor (if present). Re-selecting the same object will first call ModraUp::Tool#onCancel(1) and then activate. The viewport will then forward mouse, keyboard, VCB, getMenu, and draw events.

Parameters:

  • tool (Object, nil) Create a custom tool instance; omit or use nil for the select tool.

Returns:

  • (ModraUp::Model)

Examples:

Custom tool

class TipTool
  def activate
    ModraUp.set_status_text("tip")
  end
  def onMouseMove(flags, x, y, view)
    view.pick_helper.do_pick(x, y)
  end
end
ModraUp.active_model.select_tool(TipTool.new)

Return to selection

ModraUp.active_model.select_tool(nil)

model.add_observer(observer) ⇒ Boolean

Register a ModraUp::ModelObserver. Adding the same object a second time returns false. Transactions, group paths, saving, and component placement will dispatch corresponding callbacks.

Parameters:

  • observer (ModraUp::ModelObserver)

Returns:

  • (Boolean)

Examples:

class MyModel < ModraUp::ModelObserver
  def onTransactionCommit(model)
    model.entities.length
  end
end
ModraUp.active_model.add_observer(MyModel.new)

model.remove_observer(observer) ⇒ Boolean

Remove the model observer.

Parameters:

  • observer (ModraUp::ModelObserver)

Returns:

  • (Boolean)

Examples:

obs = ModraUp::ModelObserver.new
ModraUp.active_model.add_observer(obs)
ModraUp.active_model.remove_observer(obs)

model.start_operation(op_name) ⇒ truemodel.start_operation(op_name, disable_ui, next_transparent, transparent) ⇒ true

Start a reversible operation. Should be paired with #commit_operation or #abort_operation. disable_ui disables refreshing; next_transparent / transparent merge adjacent operations into a single undo step.

Parameters:

  • op_name (String) The name that appears in the undo stack
  • disable_ui (Boolean)
  • next_transparent (Boolean)
  • transparent (Boolean)

Returns:

  • (true)

Examples:

model = ModraUp.active_model
model.start_operation("Line", true)
model.entities.add_line([0, 0, 0], [1, 0, 0])
model.commit_operation

model.commit_operation ⇒ Boolean

Commit the current operation.

Returns:

  • (Boolean)

Examples:

ModraUp.active_model.commit_operation

model.abort_operation ⇒ Boolean

Abort the current operation and rollback.

Returns:

  • (Boolean)

Examples:

ModraUp.active_model.abort_operation

model.definitions ⇒ ModraUp::DefinitionList

Component definition table.

Returns:

  • (ModraUp::DefinitionList)

Examples:

ModraUp.active_model.definitions.add("Box")

model.line_styles ⇒ ModraUp::LineStyles

Built-in line styles (12 named styles).

Returns:

  • (ModraUp::LineStyles)

Examples:

ModraUp.active_model.line_styles["Dash"].name  #=> "Dash"

model.materials ⇒ ModraUp::Materials

Materials table of the model.

Returns:

  • (ModraUp::Materials)

Examples:

mat = ModraUp.active_model.materials.add("Joe")
mat.name  #=> "Joe"

model.rendering_options ⇒ ModraUp::RenderingOptions

The display style options for the model (edges, surfaces, background, X-ray, etc.), with key names matching SketchUp.

Returns:

  • (ModraUp::RenderingOptions)

Examples:

ModraUp.active_model.rendering_options["ModelTransparency"] = true

#shadow_info ⇒ ModraUp::ShadowInfo

model.shadow_info -> ModraUp::ShadowInfo Model shadow parameters, local time, geographical location, and derived sun direction; modifications only redraw the viewport.

Returns:

  • (ModraUp::ShadowInfo)

Examples:

ModraUp.active_model.shadow_info["DisplayShadows"] = true

model.layers ⇒ ModraUp::Layers

Layer (Tag) table. Index 0 is the default `Layer0`.

Returns:

  • (ModraUp::Layers)

Examples:

layers = ModraUp.active_model.layers
layers.add("Furniture").name  #=> "Furniture"

model.active_layer ⇒ ModraUp::Layer

The current layer. Newly drawn edges and faces appear on this layer.

Returns:

  • (ModraUp::Layer)

Examples:

ModraUp.active_model.active_layer.name  #=> "Layer0"

model.active_layer=(layer) ⇒ ModraUp::Layer

Sets the current layer. Passing nil will revert to the default layer Layer0. Dispatches ModraUp::LayersObserver#onCurrentLayerChanged when the current layer changes.

Parameters:

  • layer (ModraUp::Layer, nil) Target layer, or nil for the default layer.

Returns:

  • (ModraUp::Layer)

Raises:

  • [TypeError] Only ModraUp::Layer or nil can be passed.
  • [ArgumentError] The layer has been deleted or does not belong to this model.

Examples:

model = ModraUp.active_model
layer = model.layers.add("Doors")
model.active_layer = layer

Switch back to the default layer

model = ModraUp.active_model
model.active_layer = nil
model.active_layer.name  #=> "Layer0"

model.pages ⇒ ModraUp::Pages

Scene page table (called scenes in the interface).

Returns:

  • (ModraUp::Pages)

Examples:

ModraUp.active_model.pages.add("Plan")

model.attribute_dictionaries ⇒ ModraUp::AttributeDictionaries, nil

Collection of model-level attribute dictionaries. Returns nil if no dictionary exists.

Returns:

  • (ModraUp::AttributeDictionaries, nil)

Examples:

ModraUp.active_model.set_attribute("temp", "k", "v")
ModraUp.active_model.attribute_dictionaries["temp"]["k"]  #=> "v"

model.attribute_dictionary(name) ⇒ ModraUp::AttributeDictionary, nilmodel.attribute_dictionary(name, create) ⇒ ModraUp::AttributeDictionary, nil

Retrieve the model-level dictionary by name. Return nil if it does not exist and the create flag is false.

Parameters:

  • name (String)
  • create (Boolean)

Returns:

  • (ModraUp::AttributeDictionary, nil)

Examples:

model = ModraUp.active_model
model.attribute_dictionary("temp")  #=> nil
model.attribute_dictionary("temp", true)
model.set_attribute("temp", "k", "v")
model.attribute_dictionary("temp")["k"]  #=> "v"

model.set_attribute(dict_name, key, value) ⇒ value

Writes a model-level attribute. An empty dictionary name or key raises an error. Inside #start_operation, the write is committed or aborted with geometry changes. Otherwise it creates a separate history entry. Values retain their type when read back. For structured data, use JSON.generate in Ruby and pass the resulting string.

Parameters:

  • dict_name (String, Symbol)
  • key (String, Symbol)
  • value (Boolean, Integer, Float, Length, String, Time, Array, Geom::Point3d, Geom::Vector3d, nil)

Returns:

  • (Object)

Raises:

  • [ArgumentError] empty dictionary name or empty key
  • [TypeError] Hash, Symbol values, entities, etc., are unsupported types

Examples:

ModraUp.active_model.set_attribute("temp", "temp", 0)
ModraUp.active_model.get_attribute("temp", "temp")  #=> 0

Convert the Hash to a JSON string.

require "json"
json = JSON.generate({"a" => 1})
ModraUp.active_model.set_attribute("temp", "h", json)
ModraUp.active_model.get_attribute("temp", "h")  #=> "{\"a\":1}"

model.get_attribute(dict_name, key, default = nil) ⇒ Object

Read the model-level attribute. If dict_name and key are Symbols, convert them to strings. Return default if the dictionary or key is missing. The return value type is the same as that written by #set_attribute.

Parameters:

  • dict_name (String, Symbol)
  • key (String, Symbol)
  • default (Object)

Returns:

  • (Object)

Examples:

model = ModraUp.active_model
model.set_attribute("temp", "k", "v")
model.get_attribute("temp", "k")  #=> "v"
model.set_attribute("temp", "n", 0)
model.get_attribute("temp", "n")  #=> 0
model.get_attribute("temp", "missing", "x")  #=> "x"

model.delete_attribute(dict_name) ⇒ nilmodel.delete_attribute(dict_name, key) ⇒ nil

Delete the entire model-level dictionary, or delete a specific key.

Parameters:

  • dict_name (String)
  • key (String)

Returns:

  • (nil)

Examples:

model = ModraUp.active_model
model.set_attribute("temp", "k", "v")
model.delete_attribute("temp", "k")
model.delete_attribute("temp")

model.path ⇒ String

Path to the saved file. Returns an empty string if the file has never been saved.

Returns:

  • (String)

Examples:

ModraUp.active_model.path

model.name ⇒ String

The name of the Model Info, independent of the file path and #title; it is an empty string if not set.

Returns:

  • (String)

Examples:

ModraUp.active_model.name

model.entityID ⇒ String

Like SketchUp, the model does not have a numeric ID; it returns a string "Model". The entities within the model use ModraUp::Entity#entityID (an integer starting from 1).

Returns:

  • (String)

Examples:

ModraUp.active_model.entityID  #=> "Model"

model.find_entity_by_id(id_or_guid) ⇒ ModraUp::Entity or nilmodel.find_entity_by_id(*ids_or_guids) ⇒ Arraymodel.find_entity_by_id([ids_or_guids]) ⇒ Array

Find an entity by its ModraUp::Entity#entityID; a string parameter finds a group/component instance by GUID. Pass a single parameter to return an entity or nil, pass multiple or an array to return an array of the same order (with nil at positions where no entity is found). entityID is valid only for the current session.

Parameters:

  • ids_or_guids [Integer, String, Array<Integer, String>]

Returns:

  • (ModraUp::Entity, nil, Array<ModraUp::Entity, nil>)

Raises:

  • ArgumentError when no parameters are provided.

Examples:

model = ModraUp.active_model
edge = model.entities.add_line([0, 0, 0], [9, 9, 9])
model.find_entity_by_id(edge.entityID) == edge  #=> true

model.find_entity_by_persistent_id(pid) ⇒ ModraUp::Entity or nilmodel.find_entity_by_persistent_id(*pids, **scope) ⇒ Arraymodel.find_entity_by_persistent_id([pids], **scope) ⇒ Array

Find by ModraUp::Entity#persistent_id. The persistent_id is saved with the model and remains unchanged upon reopening. Use boolean keywords to limit the scope: entities, definitions, layers, layer_folders, materials, pages (when any range is given, only search within the ranges set to true).

Parameters:

  • pids [Integer, Array<Integer>]

Returns:

  • (ModraUp::Entity, nil, Array<ModraUp::Entity, nil>)

Raises:

  • ArgumentError when no parameters are provided.

Examples:

model = ModraUp.active_model
pid = model.entities.add_line([0, 0, 0], [9, 9, 9]).persistent_id
model.find_entity_by_persistent_id(pid, entities: true)

model.valid? ⇒ Boolean

Returns true if the associated model is not yet closed; models opened in the background remain valid.

Returns:

  • (Boolean)

Examples:

ModraUp.active_model.valid?

model.deleted? ⇒ Boolean

Opposite of #valid?.

Returns:

  • (Boolean)

Examples:

ModraUp.active_model.deleted?

model.typename ⇒ String

Fixed as "Model".

Returns:

  • (String)

Examples:

ModraUp.active_model.typename  #=> "Model"

model.guid ⇒ String

Model version GUID. It will be updated and saved with the file upon successful modification.

Returns:

  • (String)

Examples:

ModraUp.active_model.guid

model.title ⇒ String

Not saved as a string null value, saved as a filename (without extension).

Returns:

  • (String)

Examples:

ModraUp.active_model.title  #=> ""

model.bounds ⇒ Geom::BoundingBox

The world bounding box of the model content.

Returns:

  • (Geom::BoundingBox)

Examples:

ModraUp.active_model.bounds.empty?

model.edit_transform ⇒ Geom::Transformation

Returns the transformation from the current editing context to world coordinates. At the model root it is the identity transformation.

Returns:

  • (Geom::Transformation)

Examples:

ModraUp.active_model.edit_transform.identity?

model.modified? ⇒ Boolean

Has the model been modified since the last save.

Returns:

  • (Boolean)

Examples:

ModraUp.active_model.modified?

model.number_faces ⇒ Integer

The number of live faces in the model.

Returns:

  • (Integer)

Examples:

ModraUp.active_model.number_faces

model.raytest(ray) ⇒ Array, nilmodel.raytest(ray, wysiwyg_flag) ⇒ Array, nil

Find the first hit along the ray (face or edge, including coplanar boundaries). The ray is given as [point, vector]; the second item is a Point3d when specifying two points to determine the direction; a numerical array is interpreted as a vector, and if normalization is not possible, the second item is treated as a point. On hit, returns [Geom::Point3d, Array] (point and instance path), and if no hit, returns nil. The wysiwyg_flag is default true; set to false to also query hidden entities and geometry within hidden instances.

Parameters:

  • ray (Array)
  • wysiwyg_flag (Boolean)

Returns:

  • (Array(Geom::Point3d, Array<ModraUp::Drawingelement>), nil)

Raises:

  • [ArgumentError] The ray is not a two-item array.

Examples:

ModraUp.active_model.entities.add_face([0, 0, 0], [10, 0, 0], [10, 10, 0], [0, 10, 0])
hit = ModraUp.active_model.raytest([[5, 5, 5], [0, 0, -1]])
hit[0] unless hit.nil?

model.save ⇒ Booleanmodel.save(path) ⇒ Booleanmodel.save(path, version) ⇒ Boolean

Save the model. If no path is specified and it has not been saved before, raise an ArgumentError (no dialog). The SKP writer currently only supports the 2017 format; explicitly specifying another version will return false.

Parameters:

  • path (String)
  • version (Integer) Currently supports VERSION_2017 only.

Returns:

  • (Boolean)

Raises:

  • [ArgumentError] The model has not been saved and no path was specified.

Examples:

ModraUp.active_model.save("/tmp/demo.osk3d")

model.save_copy(path) ⇒ Booleanmodel.save_copy(path, version) ⇒ Boolean

Save a copy, preserving the path, dirty state, and original model GUID. Explicitly specified versions are currently supported only up to VERSION_2017.

Parameters:

  • path (String)
  • version (Integer)

Returns:

  • (Boolean)

Examples:

ModraUp.active_model.save_copy("/tmp/demo-copy.osk3d")

model.export(path) ⇒ Booleanmodel.export(path, show_summary) ⇒ Boolean

Exports the model without changing #path. The desktop host uses its CAD plugin for 3D DWG and DXF. Other supported formats include .skp, .osk3d, GLB, OBJ, and STL. The host accepts and ignores show_summary or an options Hash.

Parameters:

  • path (String)
  • show_summary (Boolean, Hash)

Returns:

  • (Boolean)

Examples:

ModraUp.active_model.export("/tmp/demo.skp")

model.get_product_family ⇒ Integer

Product line. Returns ProLicensed consistent with ModraUp.is_pro?.

Returns:

  • (Integer)

Examples:

ModraUp.active_model.get_product_family == ModraUp::Model::ProLicensed

model.options ⇒ ModraUp::OptionsManager

Model options tree. Plugins read units by options["UnitsOptions"]["LengthUnit"], with values such as Length::Inches.

Returns:

  • (ModraUp::OptionsManager)

Examples:

ModraUp.active_model.options["UnitsOptions"]["LengthUnit"]

model.add_note(note, x, y) ⇒ ModraUp::Text

Adds a text note (annotation) to the model at the given screen-space position. Coordinates are normalised window positions: 0.0 is the top-left, 1.0 is the bottom-right.

Parameters:

  • note (String) The text content.
  • x (Numeric) Horizontal position (0..1).
  • y (Numeric) Vertical position (0..1).

Returns:

  • (ModraUp::Text)

Examples:

note = ModraUp.active_model.add_note("Hello", 0.1, 0.1)

#behavior ⇒ ModraUp::Behavior

Returns:

  • (ModraUp::Behavior) The component behavior when inserting one model into another, supporting save and undo.

#name=(name) ⇒ String

Parameters:

  • name (String)

Returns:

  • (String) Model name (independent of file path, supports undo and save).

#description ⇒ String

Returns:

  • (String) Model Description.

#description=(description) ⇒ String

Parameters:

  • description (String)

Returns:

  • (String) Model Description.

#tags ⇒ String

Returns:

  • (String) Model tags (not a layer collection).

#tags=(tags) ⇒ String

Parameters:

  • tags (String)

Returns:

  • (String) Model tags.

#active_section_planes ⇒ Array<ModraUp::SectionPlane>

Returns:

  • (Array<ModraUp::SectionPlane>) Activate the section plane and all active section planes defined in the context.

#instance_path_from_pid_path(pid_path) ⇒ ModraUp::InstancePath

Parameters:

  • pid_path (String) PID path separated by dots.

Returns:

  • (ModraUp::InstancePath)

Raises:

  • [ArgumentError] The path is invalid or discontinuous.

#drawing_element_visible?(instance_path) ⇒ Boolean

Parameters:

  • instance_path (ModraUp::InstancePath, Array)

Returns:

  • (Boolean) Determines the visibility based on the combined entity, ancestors, layers, and hidden state settings.

Raises:

  • [ArgumentError] Invalid path.

#georeferenced? ⇒ Boolean

Returns:

  • (Boolean) Does the model have a GeoReference set.

#mipmapping? ⇒ Boolean

Returns:

  • (Boolean) Do the textures use mipmap.

#mipmapping=(enabled) ⇒ Boolean

Parameters:

  • enabled (Boolean)

Returns:

  • (Boolean) The texture mipmap status.

#save_thumbnail(filename) ⇒ Boolean

Parameters:

  • filename (String)

Returns:

  • (Boolean) Save the current model thumbnail. Return false if the host is unavailable.

#place_component(componentdef, repeat) ⇒ ModraUp::Model, nil

Parameters:

  • componentdef (ModraUp::ComponentDefinition)
  • repeat (Boolean) Continues placing the component.

Returns:

  • (ModraUp::Model, nil)

Raises:

  • [ArgumentError] empty definition, group definition, or another model's definition.

model.import(path) ⇒ Booleanmodel.import(path, show_summary) ⇒ Booleanmodel.import(path, options) ⇒ Boolean

Import files into the current model by file extension. DWG/DXF files are automatically placed, while SKP/OSK3D files enter the component placement tool.

Parameters:

  • path (String) File path.
  • options (Boolean, Hash, nil) Boolean values are equivalent to show_summary (default is false), controlling the result window after success; nil is equivalent to omitting it. Hash keys can be Symbol or String, and hash values do not accept nil.

Returns:

  • (Boolean) Returns true when the import is successful or the place tool is activated, and false when the import fails.

Raises:

  • [TypeError] Recognized option type is incorrect.
  • [ArgumentError] The unit or edge length is out of the supported range.
Note: For CAD import, import_materials defaults to true. The preserve_origin, merge_coplanar_faces, and orient_faces options default to false. The legacy spelling merge_coplaner_faces is also accepted.
Note: In the CAD extension options of OpenSu, import_dimensions is enabled by default, while import_text, import_layers_as_groups, and import_linework_flattened are disabled by default.
Note: units specifies the CAD drawing units, accepting a String or Symbol, with options including model, in, ft, mm, cm, m; default is mm. Millimeters are also accepted as millimeter or millimeters. min_arc_edge_mm specifies the arc segment edge length in millimeters, with a range of 0.001 to 1e9, and a default value of 5.0.

Examples:

Import the drawing while preserving the origin and complete annotations.

ModraUp.active_model.import("floor.dwg", preserve_origin: true, import_dimensions: true)

model.inspect ⇒ String

Returns a string of the form #<Sketchup::Model:0x...>, omitting instance variables.

Returns:

  • (String)

Examples:

ModraUp.active_model.inspect

model.overlays ⇒ ModraUp::OverlaysManager

The layer manager for overlay layers in this model.

Returns:

  • (ModraUp::OverlaysManager)

Examples:

ModraUp.active_model.overlays.size

model.__mu_operation_open? ⇒ Boolean

Internal: Is there an uncommitted operation currently open (between start_operation and commit_operation)? The process runs within the open operation without creating a new one.

Returns:

  • (Boolean)

Examples:

ModraUp.active_model.__mu_operation_open?

model.layout_document ⇒ Layout::Document

A model's embedded drawing sheet document. Returns the same object each time within the same model; accessing it after the model is closed throws a TypeError.

Returns:

  • (Layout::Document)
Note: ModraUp extension. SketchUp does not have an embedded drawing sheet; LayOut drawings are in separate .layout files.

Examples:

doc = ModraUp.active_model.layout_document
doc.pages.length