Class: Sketchup::DefinitionList
Overview
A DefinitionList object holds a list of all of the ComponentDefinition objects in a model. This class contains methods for adding and retrieving definitions from the list.
Instance Method Summary # collapse
-
#[](arg) ⇒ Object
The [] method is used to retrieve a component definition from the list.
-
#add(def_name) ⇒ Sketchup::ComponentDefinition
The add method is used to add a new component definition to the definition list with the given name.
-
#add_observer(observer) ⇒ Boolean
The add_observer method is used to add an observer to the current object.
-
#at(arg) ⇒ Object
The [] method is used to retrieve a component definition from the list.
- #count ⇒ Integer
-
#each {|definition| ... } ⇒ nil
The #each method is used to iterate through all of the component definitions in the definition list.
-
#import(path, options = {}) ⇒ Sketchup::ComponentDefinition
The #import method is used to import a (non-SketchUp) 3d model file as a definition.
-
#length ⇒ Integer
The #length method is used to retrieve number of component definitions in the list.
-
#load(*args) ⇒ Sketchup::ComponentDefinition
The #load method is used to load a component from a file.
-
#load_from_url(*args) ⇒ Sketchup::ComponentDefinition
The #load_from_url method loads a component from a location specified by string url.
-
#purge_unused ⇒ Sketchup::DefinitionList
The purge_unused method is used to remove the unused component definitions.
-
#remove(definition) ⇒ Boolean
The #remove method is used to remove a component definition from the definition list with the given component definition.
-
#remove_observer(observer) ⇒ Boolean
The remove_observer method is used to remove an observer from the current object.
- #size ⇒ Integer
-
#unique_name(base_name) ⇒ String
The unique_name is used to generate a unique name for a definition based on a base_name string.
Methods inherited from Entity
#attribute_dictionaries, #attribute_dictionary, #delete_attribute, #deleted?, #entityID, #get_attribute, #inspect, #model, #parent, #persistent_id, #set_attribute, #to_s, #typename, #valid?
Instance Method Details
↑ #[](index) ⇒ Sketchup::ComponentDefinition? #[](name) ⇒ Sketchup::ComponentDefinition? #[](guid) ⇒ Sketchup::ComponentDefinition?
The [] method is used to retrieve a component definition from the list. You can give an integer index in the range 0 to length, a string which represents the GUID (a unique internal identifier), or a string that is the name of the definition.
↑ #add(def_name) ⇒ Sketchup::ComponentDefinition
The add method is used to add a new component definition to the definition list with the given name.
↑ #add_observer(observer) ⇒ Boolean
The add_observer method is used to add an observer to the current object.
↑ #[](index) ⇒ Sketchup::ComponentDefinition? #[](name) ⇒ Sketchup::ComponentDefinition? #[](guid) ⇒ Sketchup::ComponentDefinition?
The [] method is used to retrieve a component definition from the list. You can give an integer index in the range 0 to length, a string which represents the GUID (a unique internal identifier), or a string that is the name of the definition.
↑ #count ⇒ Integer
↑ #each {|definition| ... } ⇒ nil
Don't remove content from this collection while iterating over it with #each. This would change the size of the collection and cause elements to be skipped as the indices change. Instead copy the current collection to an array using to_a
and then use each
on the array, when removing content.
The #each method is used to iterate through all of the component definitions in the definition list.
↑ #import(path, options = {}) ⇒ Sketchup::ComponentDefinition
The #import method is used to import a (non-SketchUp) 3d model file as a definition.
Importers using the C API SketchUpModelImporterInterface
interface are supported (those in the Importers/
directory).
See the Importer Options file for information on creating a valid hash for the various importers.
For SketchUp models, instead use #load.
↑ #length ⇒ Integer
The #length method is used to retrieve number of component definitions in the list.
↑ #load(path) ⇒ Sketchup::ComponentDefinition #load(path, allow_newer: true) ⇒ Sketchup::ComponentDefinition
The #load method is used to load a component from a file.
↑ #load_from_url(url) ⇒ Sketchup::ComponentDefinition #load_from_url(url, load_handler) ⇒ Sketchup::ComponentDefinition
The #load_from_url method loads a component from a location specified by string url.
This method throws an exception if an url string is not given, or an error occurs during retrieval from URL and a load_handler
was not given. Optional second parameter load_handler
can be used to pass in a Ruby object that responds to the following methods:
-
cancelled?
-
onPercentChange(percent)
-
onSuccess()
-
onFailure(message_string)
↑ #purge_unused ⇒ Sketchup::DefinitionList
The purge_unused method is used to remove the unused component definitions.
↑ #remove(definition) ⇒ Boolean
The #remove method is used to remove a component definition from the definition list with the given component definition. This will remove all instances of the definition.
↑ #remove_observer(observer) ⇒ Boolean
The remove_observer method is used to remove an observer from the current object.