Class: Sketchup::ComponentDefinition
Relationships | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Drawingelement ,
Entity
|
|
Instance Chain:
self,
Comparable,
Drawingelement ,
Entity
|
|
Inherits: |
Sketchup::Drawingelement
|
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 Attribute Summary
-
#description ⇒ String
rw
The description method is used to retrieve the description of the component definition.
-
#description=(description) ⇒ String
rw
The description= method is used to set the description for the component definition.
-
#group? ⇒ Boolean
readonly
The group? method is used to determine if this component definition is used to hold the elements of a group.
-
#hidden? ⇒ Boolean
readonly
The hidden method is used to determine if this component definition should be hidden on the component browser.
-
#image? ⇒ Boolean
readonly
The image? method is used to determine if this component definition is used to define an image.
-
#insertion_point ⇒ Geom::Point3d
rw
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
rw
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.
-
#internal? ⇒ Boolean
readonly
The internal? method is used to determine if the component definition is internal to the Component Browser.
-
#live_component? ⇒ Boolean
readonly
The #live_component? method is used to identify Live Components and sub-definitions of Live Components.
-
#name ⇒ String
rw
The name method retrieves the name of the component definition.
-
#name=(name) ⇒ String
rw
The #name= method is used to set the name of the component definition.
-
#thumbnail_camera ⇒ Sketchup::Camera
rw
The #thumbnail_camera method is used to retrieve a camera representing the thumbnail associated with the component definition.
-
#thumbnail_camera=(camera)
rw
The #thumbnail_camera= method is used to set the camera for the thumbnail associated with the component definition.
Drawingelement
- Inherited
#casts_shadows= | The casts_shadows= method is used to set the |
#casts_shadows? | The casts_shadows? method is used to determine if the |
#hidden= | The hidden= method is used to set the hidden status for an element. |
#hidden? | The hidden? method is used to determine if the element is hidden. |
#layer | The layer method is used to retrieve the |
#layer= | The layer= method is used to set the layer for the drawing element. |
#material | The material method is used to retrieve the material for the drawing element. |
#material= | The material= method is used to set the material for the drawing element. |
#receives_shadows= | The receive_shadows= method is used to set the |
#receives_shadows? | The receive_shadows? method is used to determine if the |
#visible= | The visible= method is used to set the visible status for an element. |
#visible? | The visible? method is used to get the visible status for an element. |
Entity
- Inherited
Instance Method Summary
-
#<=>(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.
-
#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.
-
#guid ⇒ String
The guid method is used to retrieve the unique identifier of this component definition.
-
#instances ⇒ Array<Sketchup::ComponentInstance>
The instances method is used to return any array of ComponentInstancesfor this
ComponentDefinition
. -
#invalidate_bounds ⇒ Boolean
Invalidates the bounding box of your 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_copy(file_path) ⇒ Boolean
The #save_copy method is used to save your definition as a SketchUp file without changing the file path it is already associated with.
-
#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.
Drawingelement
- Inherited
#bounds | The |
#erase! | The |
Entity
- Inherited
#add_observer | The add_observer method is used to add an observer to the current object. |
#attribute_dictionaries | The attribute_dictionaries method is used to retrieve the |
#attribute_dictionary | The attribute_dictionary method is used to retrieve an attribute dictionary with a given name that is attached to an |
#delete_attribute | The |
#entityID | The entityID method is used to retrieve a unique ID assigned to an entity. |
#get_attribute | The |
#inspect | The |
#model | The model method is used to retrieve the model for the entity. |
#parent | The parent method is used to retrieve the parent of the entity. |
#persistent_id | The |
#remove_observer | The remove_observer method is used to remove an observer from the current object. |
#set_attribute | The set attribute is used to set the value of an attribute in an attribute dictionary with the given name. |
#to_s | The |
#typename | The typename method retrieves the type of the entity, which will be a string such as “Face”, “Edge”, or “Group”. |
Instance Attribute Details
#description ⇒ String (rw)
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 (rw)
The description= method is used to set the description for the component definition.
#group? ⇒ Boolean
(readonly)
The group? method is used to determine if this component definition is used to hold the elements of a group.
#image? ⇒ Boolean
(readonly)
The image? method is used to determine if this component definition is used to define an image.
#insertion_point ⇒ Geom::Point3d (rw)
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 (rw)
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.
#internal? ⇒ Boolean
(readonly)
The internal? method is used to determine if the component definition is internal to the Component Browser
#live_component? ⇒ Boolean
(readonly)
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.
#name ⇒ String (rw)
The name method retrieves the name of the component definition.
#name=(name) ⇒ String (rw)
The name=
method is used to set the name of the component definition.
The name should be unique to the model, if it’s not the name will automatically be made unique.
#thumbnail_camera ⇒ Sketchup::Camera (rw)
The #thumbnail_camera
method is used to retrieve a camera representing the thumbnail associated with the component definition.
#thumbnail_camera=(camera) (rw)
The #thumbnail_camera=
method is used to set the camera for the thumbnail associated with the component definition.
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.
#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.
#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.
#instances ⇒ Array<Sketchup::ComponentInstance>
The instances method is used to return any array of ComponentInstancesfor this ComponentDefinition
.
#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.
#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. 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
#save_as(file_path, version) ⇒ Boolean
Boolean
#save_as(file_path, version) ⇒ Boolean
The #save_as
method is used to save your definition as a SketchUp file at the specified file destination.
Use this method when the user has chosen a path. If you want to “silently” save out the definition, without changing the path it is associated with, use #save_copy instead.
#save_copy(file_path) ⇒ Boolean
#save_copy(file_path, version) ⇒ Boolean
Boolean
#save_copy(file_path, version) ⇒ Boolean
The #save_copy
method is used to save your definition as a SketchUp file without changing the file path it is already associated with.
This can be used to save out to a temporary file used by some other process, without having the temporary path permanentely written to the SketchUp model.
#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.