Class: Sketchup::ComponentDefinition
- Inherits:
-
DrawingElement
- Object
- DrawingElement
- Sketchup::ComponentDefinition
- Includes:
- Comparable
Overview
The ComponentDefinition class is used to define the contents for a SketchUp component. Components are a collection of entities that can be instanced and reused multiple times throughout a model. For example, you could draw a chair once, turn it into a component, and then use 6 instances of it to surround a table. Edits to the original “definition” will then propagate across all of its instances.
The ComponentDefinition class contains the global entities and settings for each definition. See the ComponentInstance class for how each copy is defined.
Starting from SketchUp 2018+, the ComponentDefinition class contains a new default attribute dictionary named “SU_DefinitionSet” with default keys named named “Price”, “Size”, “Url”. See the Help article for more information. The dictionary cannot be deleted via ruby and an ArgumentError will be raised. The key/value pairs in the dictionary can be deleted safely.
Instance Method Summary # collapse
-
#<=>(compdef2) ⇒ Integer
The <=> method is used to compare two ComponentDefinition objects for sorting.
-
#==(compdef2) ⇒ Boolean
The == method is used to test if two ComponentDefinition objects are the same (based on their address in memory).
-
#add_classification(schema_name, schema_type) ⇒ Boolean
The add_classification method is used to add a given classification to the component.
-
#add_observer(observer) ⇒ Boolean
The add_observer method is used to add an observer to the current object.
-
#behavior ⇒ Sketchup::Behavior
The behavior method is used to retrieve the Behavior object associated with a component definition.
-
#count_instances ⇒ Integer
The count_instances method is used to count the number of unique component instances in a model using this component definition.
-
#count_used_instances ⇒ Integer
The count_used_instances method is used to count the total number of component instances in a model using this component definition.
-
#description ⇒ String
The description method is used to retrieve the description of the component definition.
-
#description=(description) ⇒ String
The description= method is used to set the description for the component definition.
-
#entities ⇒ Sketchup::Entities
The entities method retrieves a collection of all the entities in the component definition.
-
#get_classification_value(path) ⇒ Object?
The get_classification_value method is used to retrieve the value from a classification attribute given a key path.
-
#group? ⇒ Boolean
The group? method is used to determine if this component definition is used to hold the elements of a group.
-
#guid ⇒ String
The guid method is used to retrieve the unique identifier of this component definition.
-
#hidden? ⇒ Boolean
The hidden method is used to determine if this component definition should be hidden on the component browser.
-
#image? ⇒ Boolean
The image? method is used to determine if this component definition is used to define an image.
-
#insertion_point ⇒ Geom::Point3d
deprecated
Deprecated.
SketchUp 2020.0 removed the insertion point feature. The getter will always return the origin point and the setter becomes a no-op.
-
#insertion_point=(point) ⇒ Geom::Point3d
deprecated
Deprecated.
SketchUp 2020.0 removed the insertion point feature. The getter will always return the origin point and the setter becomes a no-op.
-
#instances ⇒ Array<Sketchup::ComponentInstance>
The instances method is used to return any array of ComponentInstancesfor this ComponentDefinition.
-
#internal? ⇒ Boolean
The internal? method is used to determine if the component definition is internal to the Component Browser.
-
#invalidate_bounds ⇒ Boolean
Invalidates the bounding box of your definition.
-
#live_component? ⇒ Boolean
The #live_component? method is used to identify Live Components and sub-definitions of Live Components.
-
#name ⇒ String
The name method retrieves the name of the component definition.
-
#name=(name) ⇒ String
The name= method is used to set the name of the component definition.
-
#path ⇒ String
The path method is used to retrieve the path where the component was loaded.
-
#refresh_thumbnail ⇒ nil
The refresh_thumbnail method is used to force SketchUp to regenerate the thumbnail image that appears in the component browser.
-
#remove_classification(schema_name, schema_type) ⇒ Boolean
The remove_classification method is used to remove a given classification from the component.
-
#remove_observer(observer) ⇒ Boolean
The remove_observer method is used to remove an observer from the current object.
-
#save_as(file_path) ⇒ Boolean
The save_as method is used to save your definition as a SketchUp file at the specified file destination.
-
#save_thumbnail(filename) ⇒ Boolean
Saves a component thumbnail image.
-
#set_classification_value(path, value) ⇒ Boolean
The set_classification_value method is used to set the value of a classification attribute given a key path.
Instance Method Details
↑ #<=>(compdef2) ⇒ Integer
The <=> method is used to compare two ComponentDefinition objects for sorting. The comparison is done based on the component name.
↑ #==(compdef2) ⇒ Boolean
The == method is used to test if two ComponentDefinition objects are the same (based on their address in memory).
↑ #add_classification(schema_name, schema_type) ⇒ Boolean
The add_classification method is used to add a given classification to the component.
Note that you cannot classify image definitions.
↑ #add_observer(observer) ⇒ Boolean
The add_observer method is used to add an observer to the current object.
↑ #behavior ⇒ Sketchup::Behavior
The behavior method is used to retrieve the Behavior object associated with a component definition.
↑ #count_instances ⇒ Integer
The count_instances method is used to count the number of unique component instances in a model using this component definition. This does not represent the total number of instances placed in the model as it doesn't take into account instances inside unused definitions.
↑ #count_used_instances ⇒ Integer
The count_used_instances method is used to count the total number of component instances in a model using this component definition. This method takes into account the full hierarchy of the model.
↑ #description ⇒ String
The description method is used to retrieve the description of the component definition.
Component definitions do not have a description, by default.
↑ #description=(description) ⇒ String
The description= method is used to set the description for the component definition.
↑ #entities ⇒ Sketchup::Entities
The entities method retrieves a collection of all the entities in the component definition
↑ #get_classification_value(path) ⇒ Object?
The get_classification_value method is used to retrieve the value from a classification attribute given a key path.
↑ #group? ⇒ Boolean
The group? method is used to determine if this component definition is used to hold the elements of a group.
↑ #guid ⇒ String
The guid method is used to retrieve the unique identifier of this component definition. The guid changes after the component definition is modified and the component edit is exited.
↑ #hidden? ⇒ Boolean
The hidden method is used to determine if this component definition should be hidden on the component browser.
↑ #image? ⇒ Boolean
The image? method is used to determine if this component definition is used to define an image.
↑ #insertion_point ⇒ Geom::Point3d
SketchUp 2020.0 removed the insertion point feature. The getter will always return the origin point and the setter becomes a no-op.
The insertion_point method is used to retrieve the Point3d object where the component was inserted.
↑ #insertion_point=(point) ⇒ Geom::Point3d
SketchUp 2020.0 removed the insertion point feature. The getter will always return the origin point and the setter becomes a no-op.
Sets the insertion point of your definition.
↑ #instances ⇒ Array<Sketchup::ComponentInstance>
The instances method is used to return any array of ComponentInstancesfor this ComponentDefinition.
↑ #internal? ⇒ Boolean
The internal? method is used to determine if the component definition is internal to the Component Browser
↑ #invalidate_bounds ⇒ Boolean
Invalidates the bounding box of your definition. This command forces the update of the bounding box of definition while inside an operation. See Model.start_operation for how to start an operation.
This method is useful if you make changes to your geometry using the Ruby API and then need to know your bounding box size. This method forces SketchUp to recalculate the definition's bounding box when you choose.
↑ #live_component? ⇒ Boolean
These components are parametrically generated and API users should not modify them.
The #live_component? method is used to identify Live Components and sub-definitions of Live Components.
↑ #refresh_thumbnail ⇒ nil
The refresh_thumbnail method is used to force SketchUp to regenerate the thumbnail image that appears in the component browser. This is useful if you've used the API to change the geometry of your component and would like the thumbnail to match.
↑ #remove_classification(schema_name, schema_type) ⇒ Boolean
The remove_classification method is used to remove a given classification from the component.
Note that you cannot classify image definitions.
↑ #remove_observer(observer) ⇒ Boolean
The remove_observer method is used to remove an observer from the current object.
↑ #save_as(file_path) ⇒ Boolean
The save_as method is used to save your definition as a SketchUp file at the specified file destination.
↑ #save_thumbnail(filename) ⇒ Boolean
Saves a component thumbnail image. The image format is specified by the file extension of filePath. Supported image formats are bmp, jpg, png, tif, pct, and gif.
↑ #set_classification_value(path, value) ⇒ Boolean
The set_classification_value method is used to set the value of a classification attribute given a key path.