Class: Sketchup::Entity
- Inherits:
-
Object
- Object
- Sketchup::Entity
- Defined in:
- SketchUp/Sketchup/Entity.rb
Overview
This is the base class for all SketchUp entities. Entities are basically anything that can be contained in a model, including Drawingelements such as Edges, SectionPlanes, Groups, etc. and entities that relate to those Drawingelements, such as Loops, Layers, etc.
Keep in mind that the methods below are available on all subclasses. For example, an Edge’s parent class is Drawingelement, and a Drawingelement’s parent class is Entity. Therefore an Edge has all of the methods defined in Drawingelement and Entity.
The Object.is_a? method is the common way of determining what sort of Entity you’re dealing with.
Direct Known Subclasses
AttributeDictionaries, AttributeDictionary, Axes, Behavior, Curve, DefinitionList, Drawingelement, EdgeUse, Layer, Layers, LineStyle, LineStyles, Loop, Material, Materials, Page, Pages, RenderingOptions, ShadowInfo, Style, Styles, Texture, Vertex
Instance Method Summary collapse
-
#add_observer(observer) ⇒ Boolean
The add_observer method is used to add an observer to the current object.
-
#attribute_dictionaries ⇒ Sketchup::AttributeDictionaries?
The attribute_dictionaries method is used to retrieve the AttributeDictionaries collection attached to the entity.
-
#attribute_dictionary(name, create) ⇒ Sketchup::AttributeDictionary?
The attribute_dictionary method is used to retrieve an attribute dictionary with a given name that is attached to an Entity.
-
#delete_attribute(*args) ⇒ Object
The #delete_attribute method is used to delete an attribute from an entity.
-
#deleted? ⇒ Boolean
The deleted? method is used to determine if your entity is still valid (not deleted by another script, for example.).
-
#entityID ⇒ Integer
The entityID method is used to retrieve a unique ID assigned to an entity.
-
#get_attribute(dict_name, key, default_value = nil) ⇒ Object
The #get_attribute method is used to retrieve the value of an attribute in the entity’s attribute dictionary.
-
#inspect ⇒ String
The to_s method is used to retrieve the string representation of the entity.
-
#model ⇒ Sketchup::Model
The model method is used to retrieve the model for the entity.
-
#parent ⇒ Sketchup::ComponentDefinition, Sketchup::Model
The parent method is used to retrieve the parent of the entity.
-
#persistent_id ⇒ Integer
The #persistent_id method is used to retrieve a unique persistent id assigned to an entity.
-
#remove_observer(observer) ⇒ Boolean
The remove_observer method is used to remove an observer from the current object.
-
#set_attribute(dict_name, key, value) ⇒ Object
The set attribute is used to set the value of an attribute in an attribute dictionary with the given name.
-
#to_s ⇒ String
The to_s method is used to retrieve the string representation of the entity.
-
#typename ⇒ String
The typename method retrieves the type of the entity, which will be a string such as “Face”, “Edge”, or “Group”.
-
#valid? ⇒ Boolean
The valid? method is used to determine if your entity is still valid (not deleted by another script, for example.).
Instance Method Details
#add_observer(observer) ⇒ Boolean
The add_observer method is used to add an observer to the current object.
50 51 |
# File 'SketchUp/Sketchup/Entity.rb', line 50 def add_observer(observer) end |
#attribute_dictionaries ⇒ Sketchup::AttributeDictionaries?
The attribute_dictionaries method is used to retrieve the AttributeDictionaries collection attached to the entity.
84 85 |
# File 'SketchUp/Sketchup/Entity.rb', line 84 def attribute_dictionaries end |
#attribute_dictionary(name, create) ⇒ Sketchup::AttributeDictionary?
The attribute_dictionary method is used to retrieve an attribute dictionary with a given name that is attached to an Entity.
121 122 |
# File 'SketchUp/Sketchup/Entity.rb', line 121 def attribute_dictionary(name, create) end |
#delete_attribute(dictionary_name) ⇒ Boolean #delete_attribute(dictionary_name, key) ⇒ Boolean
In SketchUp 2018, special attribute dictionaries have been added. The name of these dictionaries are “SU_InstanceSet” and “SU_DefinitionSet”. The dictionaries cannot be deleted via ruby and an ArgumentError will be raised. The key/value pairs in the dictionary can be deleted safely.
The return values are fixed in SketchUp 2019 M0.
The #delete_attribute method is used to delete an attribute from an entity.
If only the dictionary_name is given, then it deletes the entire AttributeDictionary. Otherwise, #delete_attribute deletes the attribute with the given key from the given dictionary.
168 169 |
# File 'SketchUp/Sketchup/Entity.rb', line 168 def delete_attribute(*args) end |
#deleted? ⇒ Boolean
The deleted? method is used to determine if your entity is still valid (not deleted by another script, for example.)
195 196 |
# File 'SketchUp/Sketchup/Entity.rb', line 195 def deleted? end |
#entityID ⇒ Integer
The entityID method is used to retrieve a unique ID assigned to an entity.
The entityID is not persistent between sessions.
221 222 |
# File 'SketchUp/Sketchup/Entity.rb', line 221 def entityID end |
#get_attribute(dict_name, key, default_value = nil) ⇒ Object
The #get_attribute method is used to retrieve the value of an attribute in the entity’s attribute dictionary.
If the third parameter, default_value
, is not passed and there is no attribute that matches the given name, it returns nil
.
If default_value
is provided and there is no matching attribute it returns the given value. It does not create an attribute with that name though.
255 256 |
# File 'SketchUp/Sketchup/Entity.rb', line 255 def get_attribute(dict_name, key, default_value = nil) end |
#inspect ⇒ String
The to_s method is used to retrieve the string representation of the entity.
283 284 |
# File 'SketchUp/Sketchup/Entity.rb', line 283 def inspect end |
#model ⇒ Sketchup::Model
The model method is used to retrieve the model for the entity.
310 311 |
# File 'SketchUp/Sketchup/Entity.rb', line 310 def model end |
#parent ⇒ Sketchup::ComponentDefinition, Sketchup::Model
The parent method is used to retrieve the parent of the entity.
The parent will be a ComponentDefinition, a Group, or a Model, whatever the entity is contained within.
341 342 |
# File 'SketchUp/Sketchup/Entity.rb', line 341 def parent end |
#persistent_id ⇒ Integer
Only a subset of entity types support PIDs. Refer to the table below for which and when support was added. In general it is entities that you can iterate over in a Sketchup::Entities collection.
The #persistent_id method is used to retrieve a unique persistent id assigned to an entity.
The persistent id persistent between sessions.
- SketchUp 2018
- SketchUp 2017
-
Polyline3d entities exposed only as Drawingelement Use #typename to determine if a Drawingelement is a “Polyline3d”.
392 393 |
# File 'SketchUp/Sketchup/Entity.rb', line 392 def persistent_id end |
#remove_observer(observer) ⇒ Boolean
The remove_observer method is used to remove an observer from the current object.
410 411 |
# File 'SketchUp/Sketchup/Entity.rb', line 410 def remove_observer(observer) end |
#set_attribute(dict_name, key, value) ⇒ Object
The set attribute is used to set the value of an attribute in an attribute dictionary with the given name.
This method will create a new AttributeDictionary if none exists.
Note, a bug prior to SketchUp 2015 would corrupt the model if the key is an empty string. This also includes values that will evaluate to empty strings, such as nil.
453 454 |
# File 'SketchUp/Sketchup/Entity.rb', line 453 def set_attribute(dict_name, key, value) end |
#to_s ⇒ String
The to_s method is used to retrieve the string representation of the entity.
481 482 |
# File 'SketchUp/Sketchup/Entity.rb', line 481 def to_s end |
#typename ⇒ String
The typename method retrieves the type of the entity, which will be a string such as “Face”, “Edge”, or “Group”.
509 510 |
# File 'SketchUp/Sketchup/Entity.rb', line 509 def typename end |
#valid? ⇒ Boolean
The valid? method is used to determine if your entity is still valid (not deleted by another script, for example.)
This method is functionally identical to the deleted? method.
538 539 |
# File 'SketchUp/Sketchup/Entity.rb', line 538 def valid? end |