Class: Sketchup::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/sketchup-api-stubs/stubs/Sketchup/Model.rb

Overview

This is the interface to a SketchUp model. The model is the 3D drawing that the user is working with, and it serves as the “entry point” for most Ruby API interactions. The Sketchup.active_model method gives you a handle to the current model, and from there you can use the model-level methods to start getting information and making changes.

Constants: Product Family

  • Model::ProTrial

  • Model::ProLicensed

  • Model::MakeTrial

  • Model::MakeTrialExpired

Examples:

# Grab a handle to the currently active model (aka the one the user is
# looking at in SketchUp.)
model = Sketchup.active_model

# Grab other handles to commonly used collections inside the model.
entities = model.entities
layers = model.layers
materials = model.materials
component_definitions = model.definitions
selection = model.selection

# Now that we have our handles, we can start pulling objects and making
# method calls that are useful.
first_entity = entities[0]
UI.messagebox("First thing in your model is a #{first_entity.typename}")

number_materials = materials.length
UI.messagebox("Your model has #{number_materials} materials.")

new_edge = entities.add_line([0,0,0], [500,500,0])

Version:

  • SketchUp 6.0

Constant Summary collapse

Make =

Constants

nil
MakeTrial =

Stub value.

nil
ProLicensed =

Stub value.

nil
ProTrial =

Stub value.

nil
VERSION_2013 =

Stub value.

nil
VERSION_2014 =

Stub value.

nil
VERSION_2015 =

Stub value.

nil
VERSION_2016 =

Stub value.

nil
VERSION_2017 =

Stub value.

nil
VERSION_2018 =

Stub value.

nil
VERSION_2019 =

Stub value.

nil
VERSION_2020 =

Stub value.

nil
VERSION_3 =

Stub value.

nil
VERSION_4 =

Stub value.

nil
VERSION_5 =

Stub value.

nil
VERSION_6 =

Stub value.

nil
VERSION_7 =

Stub value.

nil
VERSION_8 =

Stub value.

nil

Instance Method Summary collapse

Instance Method Details

#abort_operationBoolean

The abort_operation method aborts the current operation started with the start_operation method.

The abort_operation method is normally called from inside of a rescue clause to cancel an operation if something goes wrong.

Examples:

status = model.abort_operation

Returns:

  • (Boolean)

    true if successful, false if unsuccessful

Version:

  • SketchUp 6.0



81
82
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 81

def abort_operation
end

#active_entitiesSketchup::Entities

Returns an Entities object which contains the entities in the open group or component instance. If no group or component is open for editing then this will be the same as #entities.

To perform actions upon the current set of entities the user is working with then this is the method to use. Entities selected by the user will be a subset of the active entities.

Examples:

model = Sketchup.active_model
entities = model.active_entities
entities.each { |entity| puts "#{entity} (#{entity.class})" }

Returns:

See Also:

Version:

  • SketchUp 6.0



102
103
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 102

def active_entities
end

#active_layerSketchup::Layer

The #active_layer method retrieves the active Layer.

The default layer in SketchUp is layer 0.

Examples:

model = Sketchup.active_model
layer = model.active_layer

Returns:

Version:

  • SketchUp 6.0



116
117
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 116

def active_layer
end

#active_layer=(layer) ⇒ Sketchup::Layer

The #active_layer= method sets the active Layer object.

Examples:

model = Sketchup.active_model
layers = model.layers
layer = layers.add('My Layer')
model.active_layer = layer

Parameters:

Returns:

Version:

  • SketchUp 6.0



133
134
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 133

def active_layer=(layer)
end

#active_pathArray<Sketchup::Drawingelement>?

Returns an array containing the sequence of entities the user has double-clicked on for editing. This allows one to determine whether they are in component edit mode and where in the model they are.

For example, if a user has double-clicked into a component to edit its geometry, and then double clicked into a sub-group to edit that, the active_path might contain:

[<Sketchup::ComponentInstance>, <Sketchup::Group>]

Examples:

active_path = Sketchup.active_model.active_path

Returns:

Version:

  • SketchUp 7.0



153
154
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 153

def active_path
end

#active_path=(instance_path) ⇒ Sketchup::Model

Note:

An instance path can only be opened if the instances are not locked. This also include instances of the same component definition that are not on the given path. A definition cannot be edited if any of its instances are locked.

Note:

Open/close operations are special operations in SketchUp which has to be treated with special care.

The #active_path= method is used to open a given instance path for editing.

It is expected that no entities are modified in an operation that opens/closes instances.

To ensure that undo/redo is done correctly this method breaks up any open Ruby operations into a set of chained operations:

If the API user tries to do this:

model.start_operation('...', true)
model.entities.add_face(...)
model.active_path = instance_path
model.entities.add_face(...)
model.commit_operation

Then the method will break it up to something like this:

model.start_operation('...', true)
model.entities.add_face(...)
model.commit_operation

model.start_operation('...', true, false, true)
model.active_path = instance_path
model.commit_operation

model.start_operation('...', true, false, true)
model.entities.add_face(...)
model.commit_operation

For the end user this will be experienced as a single operation. For the API user the side-effect is multiple transaction notifications.

Examples:

Open an instance

model = Sketchup.active_model
instance = model.active_entities.grep(Sketchup::ComponentInstance).first
instance_path = Sketchup::InstancePath.new([instance])
model.active_path = instance_path

Close all instances

model = Sketchup.active_model
model.active_path = nil

Parameters:

Returns:

Raises:

  • (ArgumentError)

    if the instance path is not valid.

  • (ArgumentError)

    if the instance path contains locked instances.

  • (ArgumentError)

    if the instance path contains instances who’s siblings are locked.

Version:

  • SketchUp 2020.0



220
221
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 220

def active_path=(instance_path)
end

#active_viewSketchup::View

The #active_view method returns the active View object for this model.

Examples:

model = Sketchup.active_model
view = model.active_view

Returns:

Version:

  • SketchUp 6.0



232
233
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 232

def active_view
end

#add_note(note, x, y) ⇒ Sketchup::Text

Add a text note to the Model. The position of the note is given as relative window positions between 0 and 1. For example, the following command would create a note that start 1/10 of the ways down the screen from the upper left corner of the window.

Examples:

model = Sketchup.active_model
# Add a note 1/10 ways down the screen and 1/10 ways right from the
# upper left corner of model window.
note = Sketchup.active_model.add_note('Hello World', 0.1, 0.1)

Parameters:

  • note (String)

    A string note.

  • x (Numeric)

    A distance along the x axis between 0 and 1.

  • y (Numeric)

    A distance along the y axis between 0 and 1.

Returns:

  • (Sketchup::Text)

    a note object or an exception if it is unsuccessful.

Version:

  • SketchUp 6.0



259
260
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 259

def add_note(note, x, y)
end

#add_observer(observer) ⇒ Boolean

The add_observer method is used to add an observer to the current object.

Examples:

model = Sketchup.active_model
observer = Sketchup::ModelObserver.new
status = model.add_observer(observer)

Parameters:

  • observer (Object)

    An observer.

Returns:

  • (Boolean)

    true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0



275
276
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 275

def add_observer(observer)
end

#attribute_dictionariesSketchup::AttributeDictionaries

The #attribute_dictionaries method retrieves the AttributeDictionaries object that is associated with the Model.

Examples:

model = Sketchup.active_model
dictionaries = model.attribute_dictionaries
if dictionaries
  # Code to do something if attribute dictionaries exist (usually you
  # parse the array of dictionaries.
else
  # Code to do something if attribute dictionaries do not exist.
end

Returns:

  • (Sketchup::AttributeDictionaries)

    the AttributeDictionaries object associated with the entity, or nil if there are no attribute_dictionary objects associated with the model. Care must be taken if nil is returned, for example: invoking attribute_dictionaries.length will throw a NoMethodError exception, not return 0.

Version:

  • SketchUp 6.0



299
300
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 299

def attribute_dictionaries
end

#attribute_dictionary(name, create = false) ⇒ Sketchup::AttributeDictionary

Returns the Sketchup::AttributeDictionary object that is specified by name. If the model does not have an attribute dictionary that corresponds to name, returns either nil, or a creates an attribute dictionary. If the optional second argument is true, and there is no attribute dictionary that corresponds to name, a new attribute dictionary is created.

Examples:

model = Sketchup.active_model
create_if_empty = true
dictionary = model.attribute_dictionary('name', create_if_empty)

Parameters:

  • name (String)

    The name of the dictionary you are attempting to retrieve.

  • create (Boolean) (defaults to: false)

    if set to true an attribute dictionary of the given “name” will be created if not found.

Returns:

Version:

  • SketchUp 6.0



326
327
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 326

def attribute_dictionary(name, create = false)
end

#axesSketchup::Axes

The #axes method returns the drawing axes for the model.

Examples:

# Point for a rectangle.
points = [
  Geom::Point3d.new( 0,  0, 0),
  Geom::Point3d.new(10,  0, 0),
  Geom::Point3d.new(10, 20, 0),
  Geom::Point3d.new( 0, 20, 0)
]
# Transform the points so they are local to the model axes. Otherwise
# they would be local to the model origin.
tr = Sketchup.active_model.axes.transformation
points.each { |point| point.transform!(tr) }
Sketchup.active_model.active_entities.add_face(points)

Returns:

Version:

  • SketchUp 2016



348
349
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 348

def axes
end

#behaviorSketchup::Behavior

The behavior method retrieves the behavior of the model.

Examples:

model = Sketchup.active_model
behavior = model.behavior

Returns:

Version:

  • SketchUp 6.0



360
361
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 360

def behavior
end

#boundsGeom::BoundingBox

The #bounds method retrieves the bounding box of the model.

Examples:

model = Sketchup.active_model
bounds = model.bounds

Returns:

Version:

  • SketchUp 6.0



372
373
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 372

def bounds
end

#classificationsSketchup::Classifications

The #classifications method is used to retrieve the Classifications object for this model.

Examples:

model = Sketchup.active_model
c = model.classifications

Returns:

Version:

  • SketchUp 2015



385
386
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 385

def classifications
end

#close(ignore_changes = false) ⇒ nil

The close method is used to close this model. On Mac OS, only the active model can be closed. On Windows, since there can be only one document open, this method will perform a File/New operation.

Examples:

Sketchup.file_new
model = Sketchup.active_model
model.close

Parameters:

  • ignore_changes (Boolean) (defaults to: false)

    If true, model changes will be ignored and save prompts will be suppressed. If false, changes will not be ignored and save prompts will be displayed normally.

Returns:

  • (nil)

Version:

  • SketchUp 2015



406
407
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 406

def close(ignore_changes = false)
end

#close_activeBoolean

Note:

Before SketchUp 2014 this method had a bug where it didn’t create an undo operation and that could lead to corrupted geometry when undo/redo was used after invoking this method.

The #close_active method is used to close the currently active (open) group or component.

Examples:

model = Sketchup.active_model
status = model.close_active

Returns:

  • (Boolean)

    true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0



423
424
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 423

def close_active
end

#commit_operationBoolean

The commit_operation method commits an operation for undo.

The commit_operation method is normally called at the end of a method to commit the operation that the method performs.

Examples:

status = model.commit_operation

Returns:

  • (Boolean)

    true if successful, false if unsuccessful

Version:

  • SketchUp 6.0



437
438
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 437

def commit_operation
end

#definitionsSketchup::DefinitionList

The #definitions method retrieves a definition list containing all of the component definitions in the model.

Examples:

model = Sketchup.active_model
definitions = model.definitions

Returns:

Version:

  • SketchUp 6.0



450
451
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 450

def definitions
end

#descriptionString

The description method retrieves a description of the model as found in the Model Info > Files panel.

The returned description can be empty. The default description for all models is empty.

Examples:

model = Sketchup.active_model
description = model.description

Returns:

  • (String)

    a description if successful.

Version:

  • SketchUp 6.0



466
467
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 466

def description
end

#description=(description) ⇒ String

The #description= method sets the description of the model.

Examples:

model = Sketchup.active_model
description = model.description = "This is a model of a house on the " <<
  "North West Corner of 10th and Dolores Street in Carmel, California"

Parameters:

  • description (String)

    the description string to be set.

Returns:

Version:

  • SketchUp 6.0



482
483
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 482

def description=(description)
end

#drawing_element_visible?(instance_path) ⇒ Boolean

The #drawing_element_visible? method reports whether the given drawing element in an instance path is visible given the current model options.

Examples:

Traversing every visible entity in the model

module Example

  def self.instance?(entity)
    entity.is_a?(Sketchup::ComponentInstance) || entity.is_a?(Sketchup::Group)
  end

  # Walk the visible entities in the model, taking into account
  # "DrawHiddenGeometry" and "DrawHiddenObjects" rendering options.
  def self.walk(entities, transformation = IDENTITY, path = [], &block)
    entities.each { |entity|
      entity_path = path + [entity]
      next unless entity.model.drawing_element_visible?(entity_path)
      block.call(entity, transformation, path)
      if instance?(entity)
        child_entities = entity.definition.entities
        child_transformation = transformation * entity.transformation
        walk(child_entities, child_transformation, entity_path, &block)
      end
    }
  end

end

model = Sketchup.active_model
Example.walk(model.entities) do |entity, transformation, path|
  # Do something to every visible entity in the model...
end

Parameters:

Returns:

  • (Boolean)

Raises:

  • (ArgumentError)

    if the instance_path is not valid.

See Also:

Version:

  • SketchUp 2020.0



530
531
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 530

def drawing_element_visible?(instance_path)
end

#edit_transformGeom::Transformation

Returns the transformation of the current component edit session. If a user has double-clicked to edit a component’s geometry, this will return the transformation of that component, relative to its parent’s origin. This allows one to correctly calculate “local” transformations of a given entity regardless of whether the user is in edit mode.

Examples:

Sketchup.active_model.edit_transform

Returns:

Version:

  • SketchUp 7.0



545
546
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 545

def edit_transform
end

#entitiesSketchup::Entities

Note:

This does not return a collection of all the entities in the model, only the top level node of the model hierarchy. To get to all entities in a model you must recursivly traverse the model.

The #entities method returns an Entities object containing the entities in the root of model.

Examples:

model = Sketchup.active_model
entities = model.entities

Returns:

Version:

  • SketchUp 6.0



562
563
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 562

def entities
end

#export(filename, show_summary = false) ⇒ Boolean #export(filename, options) ⇒ Boolean

The export method is used to export a given file format. It knows which format to export based on the file extension you place on the file name. For example, a filename of “thing.obj” will export an OBJ file, whereas “thing.dae” will export a COLLADA file.

For SketchUp Pro 7.1+, valid extensions include dae, kmz, 3ds, dwg, dxf, fbx, obj, wrl, and xsi. SketchUp Free only supports dae and kmz.

Format Support Changes:

  • SketchUp 7.1 added COLLADA (.dae) export capability.

  • SketchUp Pro 2015+ added IFC export capability.

  • SketchUp Pro 2016+ added PDF export capability.

  • SketchUp Pro 2018+ added options for all 3D exporters.

See the Exporter Options file for information on creating a valid hash for the various exporters.

Examples:

General use

model = Sketchup.active_model
show_summary = true

# Export dwg file on a PC, showing a summary when complete.
status = model.export('c:\my_export.dwg', show_summary)

# Export kmz file on Mac (note the absolute file path), without summary.
status = model.export('/Library/my_export.kmz')

# Export pdf file on a PC, showing a summary when complete.
options_hash = { :show_summary => true,
                 :output_profile_lines => false,
                 :map_fonts => false,
                 :model_units => Length::Meter }
status = model.export('c:/my_export.pdf', options_hash)

# Or for a COLLADA (.dae) file.
options_hash = { :triangulated_faces => true,
                 :doublesided_faces => true,
                 :edges => false,
                 :author_attribution => false,
                 :texture_maps => true,
                 :selectionset_only => false,
                 :preserve_instancing => true }
status = model.export('c:/my_export.dae', options_hash)

IFC Example

model = Sketchup.active_model
# If no IFC types are passed in, then no geometry will be exported.
options_hash = { :hidden_geometry => true,
                 :ifc_mapped_items => true,
                 :ifc_types => ['IfcBuilding', 'IfcDoor']}
status = model.export('c:/my_export.ifc', options_hash)

Overloads:

  • #export(filename, show_summary = false) ⇒ Boolean

    Parameters:

    • filename (String)

      The name of the file to export.

    • show_summary (Boolean) (defaults to: false)

      Boolean to show summary dialog.

    Returns:

    • (Boolean)
  • #export(filename, options) ⇒ Boolean

    Parameters:

    • filename (String)

      The name of the file to export.

    • options (Hash)

    Returns:

    • (Boolean)

Raises:

  • (ArgumentError)

    If the file extension is unsupported.

Version:

  • SketchUp 6.0



632
633
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 632

def export(*args)
end

#find_entity_by_id(ids_or_array) ⇒ Array<Sketchup::Entity, nil>

Finds and returns entities by their entityID or GUID.

GUIDs looked up are only relevant to Group and ComponentInstance as these GUIDs are persistent. ComponentDefinition and Model GUIDs are not persistent and are not looked up.

When given an array of IDs, an array is returned with a 1:1 mapping to the input arguments. This array may contain nil values if some ids were not found. You cannot look up a mix of entityIDs and GUIDs in the same call.

Examples:

model = Sketchup.active_model

# Look up by entityID.
entity_id = model.entities.add_line([0,0,0], [9,9,9]).entityID
entity = model.find_entity_by_id(entity_id)

# Look up by GUID.
guid = model.entities.add_group.guid
entity = model.find_entity_by_id(guid)

# Look up multiple.
entities = model.find_entity_by_id(id1, id2, id3)
entities = model.find_entity_by_id([id1, id2, id3])
entities = model.find_entity_by_id(guid1, guid2, guid3)
entities = model.find_entity_by_id([guid1, guid2, guid3])

Parameters:

  • ids_or_array (Array<Integer, String>)

    Pass either a series of ids or a single array containing ids. Ids must either be entityID Integers or GUID Strings.

Returns:

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

    Returns an array with Entity objects for each id found and nil otherwise. Single Entity or nil when called with a single id.

Version:

  • SketchUp 2015



672
673
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 672

def find_entity_by_id(ids_or_array)
end

#find_entity_by_persistent_id(ids_or_array) ⇒ Array<Sketchup::Entity, nil>

Finds and returns entities by their persistent id.

When given an array of IDs, an array is returned with a 1:1 mapping to the input arguments. This array may contain ‘nil` values if some ids were not found.

Examples:

model = Sketchup.active_model

# Look up by persistent_id.
pid = model.entities.add_line([0,0,0], [9,9,9]).persistent_id
entity = model.find_entity_by_persistent_id(pid)

# Look up multiple.
entities = model.find_entity_by_persistent_id(id1, id2, id3)
entities = model.find_entity_by_persistent_id([id1, id2, id3])

Parameters:

  • ids_or_array (Array<Integer>)

    Pass either a series of ids or a single array containing persistent ids.

Returns:

Version:

  • SketchUp 2017



700
701
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 700

def find_entity_by_persistent_id(ids_or_array)
end

#georeferenced?Boolean

This methods determines if the model is georeferenced.

Examples:

if model.georeferenced?
  UI.messagebox('This model is georeferenced.')
else
  UI.messagebox('This model is NOT georeferenced.')
end

Returns:

  • (Boolean)

Version:

  • SketchUp 7.1



715
716
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 715

def georeferenced?
end

#get_attribute(dictname, key, defaultvalue = nil) ⇒ Object?

The get_attribute method gets the value of an attribute that in the AttributeDictionary with the given name. If no value is associated with key, or if the model does not have an attribute dictionary specified by name, the optional third parameter will be returned.

Examples:

model = Sketchup.active_model
model.set_attribute('testdictionary', 'test', 115)
value = model.get_attribute('testdictionary', 'test', 42)

Parameters:

  • dictname (String)

    The name of the dictionary containing the value.

  • key (String)

    The key containing the value.

  • defaultvalue (Object) (defaults to: nil)

    default value that will be returned if a value does not exist.

Returns:

  • (Object, nil)

    the value for a given key in the given dictionary if a value exists; the default value if a defaultvalue is provided and the value does not exist; nil if the value does not exist and no defaultvalue is provided.

Version:

  • SketchUp 6.0



745
746
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 745

def get_attribute(dictname, key, defaultvalue = nil)
end

#get_datumString

the get_datum method retrieves the datum, in the form of a string, used in UTM conversions.

Examples:

model = Sketchup.active_model
datum = model.get_datum

Returns:

  • (String)

    a datum represented as a string if successful.

Version:

  • SketchUp 6.0



758
759
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 758

def get_datum
end

#get_product_familyInteger

Returns a value which indicates the product family of the installed SketchUp application. As of SketchUp 2013, the return values are:

  • 0 = Unknown

  • 1 = Pro Trial

  • 2 = Pro

  • 3 = Pro Expired

  • 4 = Make Trial

  • 5 = Make Expired

  • 6 = Make

  • 7 = Pro License Unavailable

The Model class defines some of these values as constants as of SketchUp 2016.

Examples:

model = Sketchup.active_model
product_family = model.get_product_family
if product_family == Sketchup::Model::ProLicensed then
  puts "You are running licensed SketchUp Pro!"
end

Returns:

  • (Integer)

    the product family number.

Version:

  • SketchUp 6.0



786
787
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 786

def get_product_family
end

#guidString

The guid method retrieves the globally unique identifier, in the form of a string, for the Model. The guid will change after the model is modified and saved. The Model guid is stored with the SketchUp file; it will not change if the file is moved to another computer.

Examples:

model = Sketchup.active_model
guid = model.guid

Returns:

  • (String)

    a globally unique identifier, in the form of a string, for the model

Version:

  • SketchUp 6.0



802
803
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 802

def guid
end

#import(filename, options) ⇒ Boolean #import(filename, show_summary = false) ⇒ Boolean

The import method is used to load a file by recognizing the file extension and calling appropriate importer.

See the Importer Options file for information on creating a valid hash for the various importers.

Examples:

Import for SketchUp 2017 and older

model = Sketchup.active_model
show_summary = true
status = model.import("filename", show_summary)

Import for SketchUp 2018+ and newer

model = Sketchup.active_model
options = { :units => "model",
            :merge_coplanar_faces => true,
            :show_summary => true }
status = model.import("filename", options)

Overloads:

  • #import(filename, options) ⇒ Boolean

    Parameters:

    • filename (String)

      The input filename.

    • options (Hash)

      The options.

    Returns:

    • (Boolean)
  • #import(filename, show_summary = false) ⇒ Boolean
    Note:

    This variant is for SketchUp 2017 and earlier.

    Parameters:

    • filename (String)

      The input filename.

    • show_summary (Boolean) (defaults to: false)

      Show the summary dialog.

    Returns:

    • (Boolean)

Version:

  • SketchUp 6.0



837
838
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 837

def import(*args)
end

#instance_path_from_pid_path(pid_path) ⇒ Sketchup::InstancePath

The #instance_path_from_pid_path method returns a instance path given a string with persistent ids representing the path to the entity.

Examples:

points = [
  Geom::Point3d.new( 0,  0, 0),
  Geom::Point3d.new(10,  0, 0),
  Geom::Point3d.new(10, 20, 0),
  Geom::Point3d.new( 0, 20, 0)
]
model = Sketchup.active_model
entities = model.active_entities
group = entities.add_group
face = group.entities.add_face(points)
pid_path = "#{group.persistent_id}.#{face.persistent_id}"
# pid_path will look something like this: "658.723"
instance_path = model.instance_path_from_pid_path(pid_path)

Parameters:

  • pid_path (String)

    a string with persistent ids delimited by period.

Returns:

Raises:

  • (ArgumentError)

    if a valid instance path cannot be created from the given input path string.

See Also:

Version:

  • SketchUp 2017



869
870
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 869

def instance_path_from_pid_path(pid_path)
end

#latlong_to_point(lnglat_array) ⇒ Geom::Point3d

The latlong_to_point method converts a latitude and longitude to a Point3d object in the model. It does not actually work with a LatLong object, but operates on a 2-element array. The returned point will always be on the ground (z=0).

Examples:

# Draw a point in Boulder, Colorado (40.0170N, 105.2830W)
lnglat_array = [-105.28300, 40.01700]
model = Sketchup.active_model
local_point = model.latlong_to_point(lnglat_array)
model.entities.add_cpoint(local_point)

Parameters:

  • lnglat_array (Array(Numeric, Numeric))

    A 2-element array containing first the longitude then the latitude.

Returns:

  • (Geom::Point3d)

    a point3d object if successful, false if unsuccessful.

Version:

  • SketchUp 6.0



892
893
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 892

def latlong_to_point(lnglat_array)
end

#layersSketchup::Layers

The {#layers method retrieves a collection of all Layers objects in the model.

Examples:

model = Sketchup.active_model
layers = model.layers

Returns:

  • (Sketchup::Layers)

    a Layers object containing a collection of layers in the model

Version:

  • SketchUp 6.0



905
906
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 905

def layers
end

#line_stylesSketchup::LineStyles

The #line_styles method returns the line styles manager.

Examples:

line_styles = Sketchup.active_model.line_styles

Returns:

Version:

  • SketchUp 2019



916
917
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 916

def line_styles
end

#list_datumsArray<String>

This method retrieves an Array of all of the datums recognized by SketchUp.

Examples:

model = Sketchup.active_model
datums = model.list_datums

Returns:

  • (Array<String>)

    An Array object containing the datums supported by SketchUp

Version:

  • SketchUp 6.0



929
930
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 929

def list_datums
end

#materialsSketchup::Materials

The #materials method returns a collection of all of the materials in the model.

Examples:

model = Sketchup.active_model
materials = model.materials

Returns:

Version:

  • SketchUp 6.0



942
943
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 942

def materials
end

#mipmapping=(mipmap) ⇒ Boolean

This method can be used to turn mipmapping on or off.

Examples:

Sketchup.active_model.mipmapping = false

Parameters:

  • mipmap (Boolean)

    whether mipmapping is turned on or off.

Returns:

  • (Boolean)

    the new mipmapping setting

Version:

  • SketchUp 7.0



956
957
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 956

def mipmapping=(mipmap)
end

#mipmapping?Boolean

This method can be used to find out if mipmapping is on or off.

Examples:

mipmapping = Sketchup.active_model.mipmapping?

Returns:

  • (Boolean)

Version:

  • SketchUp 7.0



967
968
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 967

def mipmapping?
end

#modified?Boolean

The modified? method determines if the Model has been modified since the last save.

Examples:

model = Sketchup.active_model
entities = model.active_entities
# Add a group to force the status return value to be true
entities.add_group
status = model.modified?

Returns:

  • (Boolean)

Version:

  • SketchUp 6.0



983
984
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 983

def modified?
end

#nameString

The name method retrieves the string name of the model.

Examples:

model = Sketchup.active_model
name = model.name

Returns:

  • (String)

    string name of the model

Version:

  • SketchUp 6.0



995
996
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 995

def name
end

#name=(name) ⇒ String

The name= method sets the string name of the model.

Examples:

Sketchup.active_model.name = "My New Model Name"

Parameters:

  • name (String)

    new name of the model

Returns:

Version:

  • SketchUp 6.0



1009
1010
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1009

def name=(name)
end

#number_facesInteger

Returns the number faces in a model.

Examples:

model = Sketchup.active_model
number_of_faces = model.number_faces
puts "There are #{number_of_faces} faces in the model."

Returns:

  • (Integer)

Version:

  • SketchUp 7.1



1022
1023
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1022

def number_faces
end

#optionsSketchup::OptionsManager

The #options method retrieves the options manager that defines the options settings for the model.

Use the string keys instead of numerical indicies when accessing the options as the indicies are not consistent between SketchUp versions.

Examples:

# Output all options available.
options_manager = Sketchup.active_model.options
options_manager.keys.each { |options_provider|
  puts options_provider.name
  options_provider.each { |key, value|
    puts "> #{key} - #{value}"
  }
}

Returns:

Version:

  • SketchUp 6.0



1044
1045
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1044

def options
end

#pagesSketchup::Pages

The #pages method retrieves a Pages object containing all of the pages in the model.

Examples:

model = Sketchup.active_model
pages = model.pages

Returns:

Version:

  • SketchUp 6.0



1057
1058
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1057

def pages
end

#pathString

The path method retrieves the path of the file from which the model was opened.

An empty string is returned for a new model (one which has not been saved and opened.)

Examples:

model = Sketchup.active_model
path = model.path

Returns:

  • (String)

    an string containing the path for the currently opened model.

Version:

  • SketchUp 6.0



1074
1075
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1074

def path
end

#place_component(componentdef, repeat = false) ⇒ Sketchup::Model?

The place_component method places a new component in the Model using the component placement tool.

Examples:

model.place_component componentdefinition, repeat

Parameters:

  • componentdef (Sketchup::ComponentDefinition)

    A component definition object containing the definition (blueprint) for the component.

  • repeat (Boolean) (defaults to: false)

    If set to true, stay in the component placement tool and place multiple components.

Returns:

Version:

  • SketchUp 6.0



1094
1095
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1094

def place_component(componentdef, repeat = false)
end

#point_to_latlong(point) ⇒ Geom::Point3d, Geom::LatLong

The point_to_latlong method converts a point in the model to a LatLong so that you can get its latitude and longitude.

This method uses the location information set in ShadowInfo.

NOTE: SketchUp 6.0 and higher has a change where this method returns a Point3d instead of a LatLong, where the x and y values contain the LatLong coordinates.

Examples:

model = Sketchup.active_model
local_point = Geom::Point3d.new(10, 10, 10)
world_point = model.point_to_latlong(local_point)

Parameters:

Returns:

Version:

  • SketchUp 6.0



1118
1119
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1118

def point_to_latlong(point)
end

#point_to_utm(point) ⇒ Geom::UTM

This method converts a Point3d object in the Model to UTM coordinates.

This method uses the location information set in ShadowInfo. See also UTM.

Examples:

model = Sketchup.active_model
point = Geom::Point3d.new(10, 10, 10)
utm = model.point_to_utm(point)

Parameters:

Returns:

Version:

  • SketchUp 6.0



1136
1137
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1136

def point_to_utm(point)
end

#raytest(ray, wysiwyg_flag = true) ⇒ Array(Geom::Point3d, Array<Sketchup::Drawingelement>)?

Note:

The parameter wysiwyg_flag was added in SU8 M1.

The raytest method is used to cast a ray (line) through the model and return the first thing that the ray hits.

A ray is a two element array containing a point and a vector [Geom::Point3d(), Geom::Vector3d()]. The point defines the start point of the ray and the vector defines the direction. If direction can not be normalized (e.g. direction = [0, 0, 0]), direction is taken as a point the ray intersects.

Examples:

model = Sketchup.active_model
ray = [Geom::Point3d.new(1, 2, 3), Geom::Vector3d.new(4, 5, 6)]
item = model.raytest(ray, false) # Consider hidden geometry when
                                 # computing intersections.

Parameters:

  • ray (Array(Geom::Point3d, Geom::Vector3d))

    A two element array containing a point and a vector.

  • wysiwyg_flag (Boolean) (defaults to: true)

    An optional boolean, added in SU8 M1, indicating whether or not to consider hidden geometry in intersect computations. If this flag is not specified, it defaults to true (WYSIWYG) - i.e. hidden geometry is not intersected against.

Returns:

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

    an array of two values. The first value is a Point3d where the item that the ray passed through exists. The second element is the instance path array of the entity that the ray hit. For example, if the ray hits a face that is contained by a component instance the instance path would be [Component1]. If the ray hit a face that is contained by a component instance, which is contained by another component instance and so on, the instance path would be [Component1, Component2, Component3…].

Version:

  • SketchUp 6.0



1178
1179
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1178

def raytest(ray, wysiwyg_flag = true)
end

#remove_observer(observer) ⇒ Boolean

The remove_observer method is used to remove an observer from the current object.

Examples:

model = Sketchup.active_model
observer = Sketchup::ModelObserver.new
model.add_observer(observer)
status = model.remove_observer(observer)

Parameters:

  • observer (Object)

    An observer.

Returns:

  • (Boolean)

    true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0



1196
1197
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1196

def remove_observer(observer)
end

#rendering_optionsSketchup::RenderingOptions

The #rendering_options method retrieves the RenderingOptions object for this model.

Examples:

model = Sketchup.active_model
renderingoptions = model.rendering_options

Returns:

Version:

  • SketchUp 6.0



1209
1210
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1209

def rendering_options
end

#saveBoolean #save(filename) ⇒ Boolean #save(filename, version) ⇒ Boolean

Note:

A bug in SketchUp 2016 and older caused the .skb backup file written during save to be empty. The .skp file was however valid.

This method is used to save the model to a file.

Examples:

model = Sketchup.active_model
# Save the model using the current SketchUp format
filename = File.join(ENV['HOME'], 'Desktop', 'mysketchup.skp')
status = model.save(filename)
# Save the model to the current file using the current SketchUp format
status = model.save
# Save the model to the current file in SketchUp 8 format
status = model.save("", Sketchup::Model::VERSION_8)
# Save the model in SketchUp 8 format
filename = File.join(ENV['Home'], 'Desktop', 'mysketchup_v8.skp')
status = model.save("filename", Sketchup::Model::VERSION_8)

Overloads:

  • #saveBoolean

    Starting with SketchUp 2014, this parameter is optional. If no arguments are provided or the filename is an empty string, model will be saved to the file to which it is associated. It must have already been saved to a file.

  • #save(filename) ⇒ Boolean

    Parameters:

    • filename (String)

      The name of the file to save. Starting with SketchUp 2014, this parameter is optional. If not provided or an empty string, model will be saved to the file to which it is associated. It must have already been saved to a file.

  • #save(filename, version) ⇒ Boolean

    Parameters:

    • filename (String)

      The name of the file to save. Starting with SketchUp 2014, this parameter is optional. If not provided or an empty string, model will be saved to the file to which it is associated. It must have already been saved to a file.

    • version (Integer)

      (SketchUp 2014+) Optional SketchUp file format to save. If not provided, latest file format will be used. Possible values are: Sketchup::Model::VERSION_3, Sketchup::Model::VERSION_4, Sketchup::Model::VERSION_5, Sketchup::Model::VERSION_6, Sketchup::Model::VERSION_7, Sketchup::Model::VERSION_8, Sketchup::Model::VERSION_2013, Sketchup::Model::VERSION_2014, Sketchup::Model::VERSION_2015, Sketchup::Model::VERSION_2016, Sketchup::Model::VERSION_2017, Sketchup::Model::VERSION_2018, Sketchup::Model::VERSION_2019, Sketchup::Model::VERSION_2020

Returns:

  • (Boolean)

    true if successful, false if unsuccessful

Version:

  • SketchUp 6.0



1275
1276
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1275

def save(*args)
end

#save_copy(filename, version) ⇒ Boolean

This method is used to save the copy of the current model to a file.

Examples:

model = Sketchup.active_model
# Save copy of the model using the current SketchUp format
filename = File.join(ENV['Home'], 'Desktop', 'myModelCopy.skp')
status = model.save_copy(filename)
# Save copy of the model in SketchUp 8 format
filename = File.join(ENV['Home'], 'Desktop', 'mysketchupcopy_v8.skp')
status = model.save_copy(filename, Sketchup::Model::VERSION_8)

Parameters:

  • filename (String)

    The name of the file to save the model copy.

  • version (Integer)

    (SketchUp 2014+) Optional SketchUp file format to save. If not provided, latest file format will be used. Possible values are: Sketchup::Model::VERSION_3, Sketchup::Model::VERSION_4, Sketchup::Model::VERSION_5, Sketchup::Model::VERSION_6, Sketchup::Model::VERSION_7, Sketchup::Model::VERSION_8, Sketchup::Model::VERSION_2013, Sketchup::Model::VERSION_2014, Sketchup::Model::VERSION_2015, Sketchup::Model::VERSION_2016, Sketchup::Model::VERSION_2017, Sketchup::Model::VERSION_2018, Sketchup::Model::VERSION_2019, Sketchup::Model::VERSION_2020

Returns:

  • (Boolean)

    true if successful, false if unsuccessful

Version:

  • SketchUp 2014



1312
1313
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1312

def save_copy(filename, version)
end

#save_thumbnail(filename) ⇒ Boolean

The save_thumbnail method is used to save a thumbnail image to a file. The image format is specified by the file extension of filename. Supported formats are bmp, jpg, png, tif, pct, and gif.

Examples:

model = Sketchup.active_model
status = model.save_thumbnail('testthumbnail2.jpg')

Parameters:

  • filename (String)

    The name of the file, with extension, to save the thumbnail as.

Returns:

  • (Boolean)

    true if successful, false if unsuccessful

Version:

  • SketchUp 6.0



1330
1331
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1330

def save_thumbnail(filename)
end

#select_tool(tool) ⇒ Sketchup::Model

This method is used to select a SketchUp Tool object s the active tool. You must implement the SketchUp Tool interface to create a tool prior to calling this method.

The select tool is activated if you pass nil to the select_tool method. You must implement the SketchUp Tool interface to create a tool, prior to calling this method, and then instance the tool implementation and pass the object to this method. If you attempt to set the select_tool to nil in the initialize method of a tool you have written, it will be ignored.

Examples:

model = Sketchup.active_model
tool = model.select_tool(nil)

Parameters:

  • tool (Object)

    The Tool object you want to select.

Returns:

Version:

  • SketchUp 6.0



1353
1354
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1353

def select_tool(tool)
end

#selectionSketchup::Selection

This method retrieves a Selection object for the model, containing the currently selected entities. The entries in the selection list are not necessarily in the same order in which the user selected them.

Examples:

model = Sketchup.active_model
selection = model.selection

Returns:

  • (Sketchup::Selection)

    A Selection object with 0 or more entities that are currently selected.

Version:

  • SketchUp 6.0



1368
1369
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1368

def selection
end

#set_attribute(attrdictname, key, value) ⇒ Object

This method is used to set the value of an attribute in an attribute dictionary with the given name.

This method can be used create a new AttributeDictionary object, if needed.

Examples:

model = Sketchup.active_model
value = model.set_attribute('attributedictionaryname', 'key', 'value')

Parameters:

  • attrdictname (String)

    The name of the attribute dictionary whose attribute you wish to set.

  • key (String)

    The attribute name.

  • value (Object)

    The value to set.

Returns:

  • (Object)

    the value that was set

Version:

  • SketchUp 6.0



1393
1394
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1393

def set_attribute(attrdictname, key, value)
end

#set_datum(datum) ⇒ nil

This method sets the datum used in conversions between the internal coordinate system and UTM.

The default datum is WGS84. You can use the method list_datums to get a list of all of the datums supported in SketchUp. If you pass an invalid datum to set_datum, set_datum returns the default datum.

Examples:

model = Sketchup.active_model
value = model.set_datum('Adindan')

Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 6.0



1412
1413
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1412

def set_datum(datum)
end

#shadow_infoSketchup::ShadowInfo

This method is used to retrieve the shadow information for the Model.

Examples:

model = Sketchup.active_model
shadowinfo = model.shadow_info

Returns:

Version:

  • SketchUp 6.0



1424
1425
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1424

def shadow_info
end

#start_operation(op_name, disable_ui = false, next_transparent = false, transparent = false) ⇒ Boolean

Note:

Operations in SketchUp are sequential and cannot be nested. If you start a new Ruby operation while another is still open, you will implicitly close the first one.

The #start_operation method is used to notify SketchUp that a new operation (which can be undone) is starting.

The op_name argument is a description for the operation that is displayed adjacent to the Edit > Undo menu item. Make sure to provide a user friendly name for your operation.

Starting with SketchUp 7.0, there are three additional booleans that one can pass in when starting an operation. It is recommended to always set disable_ui to true. It’s left to false for default for compatibility reasons.

Examples:

Observer Operation since SU2016

class MyDefinitionsObserver < Sketchup::DefinitionObserver
  def onComponentAdded(definitions, definition)
    return if definition.deleted?
    # The operation name won't be displayed when the fourth argument is
    # +true+. It will absorb into the previous operation.
    definition.model.start_operation('Tag It', true, false, true)
    definition.set_attribute('MyExtension', 'Tag', 'You are it')
    definition.model.commit_operation
  end
end

observer = MyDefinitionsObserver.new
model = Sketchup.active_model
model.definitions.add_observer(observer)

Typical Operation

model = Sketchup.active_model
model.start_operation('Generate House', true)
model.entities.add_line([0, 0, 0], [9, 0, 0])
model.entities.add_line([9, 0, 0], [9, 0, 9])
model.commit_operation

Parameters:

  • op_name (String)

    name of the operation visible in the UI

  • disable_ui (Boolean) (defaults to: false)

    if set to true, then SketchUp’s tendency to update the user interface after each geometry change will be suppressed. This can result in much faster Ruby code execution if the operation involves updating the model in any way.

  • next_transparent (Boolean) (defaults to: false)

    Deprecated! if set to true, then whatever operation comes after this one will be appended into one combined operation, allowing the user the undo both actions with a single undo command. This flag is a highly difficult one, since there are so many ways that a SketchUp user can interrupt a given operation with one of their own. Use extreme caution and test thoroughly when setting this to true.

  • transparent (Boolean) (defaults to: false)

    if set to true, then this operation will append to the previous operation. This is particularly useful for creating observers that react to user actions without littering the undo stack with extra steps that Ruby is performing.

Returns:

  • (Boolean)

    true if successful, false if unsuccessful

Version:

  • SketchUp 6.0



1493
1494
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1493

def start_operation(op_name, disable_ui = false, next_transparent = false, transparent = false)
end

#stylesSketchup::Styles

The #styles method retrieves the styles associated with the model.

Examples:

model = Sketchup.active_model
styles = model.styles

Returns:

Version:

  • SketchUp 6.0



1505
1506
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1505

def styles
end

#tagsString

The tags method retrieves the string tags of the model.

Examples:

model = Sketchup.active_model
tags = model.tags

Returns:

  • (String)

    string tags of the model

Version:

  • SketchUp 6.0



1517
1518
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1517

def tags
end

#tags=(tags) ⇒ String

The tags= method sets the string tags of the model.

Examples:

Sketchup.active_model.tags = "Building, House, Brick"

Parameters:

  • tags (String)

    new tags of the model

Returns:

Version:

  • SketchUp 6.0



1531
1532
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1531

def tags=(tags)
end

#titleString

The tile method retrieves the name of the model. If the model is saved on disk, returns the file name without extension. Otherwise returns an empty string.

Examples:

model = Sketchup.active_model
title = model.title

Returns:

  • (String)

    the title of the model or an empty string (if the title is not set)

Version:

  • SketchUp 6.0



1546
1547
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1546

def title
end

#toolsSketchup::Tools

The #tools method is used to retrieve the current Tools object.

Examples:

model = Sketchup.active_model
tools = model.tools

Returns:

Version:

  • SketchUp 6.0



1558
1559
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1558

def tools
end

#utm_to_point(utm) ⇒ Geom::Point3d

The utm_to_point method converts a position given in UTM coordinates to a Point3d in the Model.

Examples:

model = Sketchup.active_model
utm = Geom::UTM.new([+1, "A", 0.12333333, 0.12321321])
point = model.utm_to_point(utm)

Parameters:

Returns:

Version:

  • SketchUp 6.0



1575
1576
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1575

def utm_to_point(utm)
end

#valid?Boolean

Determine if a model is a valid Sketchup::Model object. Returns false if the model has been closed.

This is useful on the mac where one can have multiple models open at the same time. In such a case, this method can tell you if the user has closed the model before you perform operations on it.

Examples:

# This is a silly example since the active model is generally going to
# be valid, but it illustrates the idea.
model = Sketchup.active_model
if model.valid?
  UI.messagebox('This model is valid.')
else
  UI.messagebox('This model is NOT valid.')
end

Returns:

  • (Boolean)

Version:

  • SketchUp 6.0



1598
1599
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Model.rb', line 1598

def valid?
end