class DefinitionList |
Parent: Entity |
|
Methods: [], add, at, count, each, length, load, unique_name |
|
Sample Code: definitionlisttests.rb |
|
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 Methods |
[] |
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 for the component definition, or a string that is the name of the component definition. |
Syntax: |
componentdefinition = definitionlist[index] componentdefinition = definitionlist[guid] componentdefinition = definitionlist["componentdefinitionname"] |
Arguments: |
index - the index for a specific component definition guid - the unique ID for the component definition “componentdefinitionname” – the name of an existing component definition |
Return Value: |
componentdefinition - a ComponentDefinition object if successful, nil if not found |
Comments: |
|
Example: |
path=Sketchup.find_support_file "BedTraditional.skp"
,"Components/Furniture/" |
add |
The add method is used to add a new component definition to the definition list with the given name. |
Syntax: |
componentdefinition = definitionlist.add "componentdefinitionname" |
Arguments: |
componentdefinitionname - the new component definition to add to the definition list |
Return Value: |
componentdefinition - the ComponentDefinition object that was added (if successful) |
Comments: |
|
Example: |
model = Sketchup.active_model |
at |
The at method is used to retrieve a component definition at a specific index. |
Syntax: |
componentdefinition = definitionlist.at[index] |
Arguments: |
index - the index of the component definition |
Return Value: |
componentdefinition - the ComponentDefinition object at the specific index if successful, nil if unsuccessful |
Comments: |
|
Example: |
model = Sketchup.active_model |
count |
The count method is an alias for length. See also length. |
Syntax: |
count = definitionlist.length |
Arguments: |
|
Return Value: |
count - the number of component definitions in the definition list if successful |
Comments: |
|
Example: |
model = Sketchup.active_model |
each |
The each method is used to iterate through all of the component definitions in the definition list. |
Syntax: |
definitionlist.each {| componentdefinition | ...} |
Arguments: |
componentdefinition – a variable that will hold each ComponentDefinition object as they are found |
Return Value: |
|
Comments: |
Throws an exception if there are no component definitions. |
Example: |
model = Sketchup.active_model |
length |
The length method is used to retrieve number of component definitions in the list. |
Syntax: |
length = definitionlist.length |
Arguments: |
|
Return Value: |
length - the number of component definitions in the definition list (if successful) |
Comments: |
|
Example: |
model = Sketchup.active_model |
load |
The load method is used to load a component from a file. |
Syntax: |
componentdefinition = definitionlist.load path |
Arguments: |
path - the path where the component definition file is located |
Return Value: |
componentdefinition - the loaded ComponentDefinition object if successful |
Comments: |
|
Example: |
path=Sketchup.find_support_file "BedTraditional.skp"
,"Components/Furniture/" |
unique_name |
The unique_name method is used to generate a unique name for a component definition. |
Syntax: |
name = definitionlist.unique_name "startingname" |
Arguments: |
"startingname" - the starting or base name which will be used to form the unique name |
Return Value: |
name - the unique name if successful |
Comments: |
|
Example: |
path=Sketchup.find_support_file "BedTraditional.skp"
,"Components/Furniture/" |