Class: Sketchup::Entity
- Inherits:
-
Object
- Object
- Sketchup::Entity
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, Drawingelement, EdgeUse, Layer, LayerFolder, 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 = false) ⇒ 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.
↑ #attribute_dictionaries ⇒ Sketchup::AttributeDictionaries?
The return value may be either nil
or an empty AttributeDictionaries collection if this entity has no AttributeDictionarys.
The attribute_dictionaries method is used to retrieve the AttributeDictionaries collection attached to the entity.
↑ #attribute_dictionary(name, create = false) ⇒ 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(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 #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.
↑ #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.
The entityID is not persistent between sessions.
↑ #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.
↑ #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.
The parent will be a ComponentDefinition, a Group, or a Model, whatever the entity is contained within.
↑ #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 2020.1
- SketchUp 2020.0
- SketchUp 2018
- SketchUp 2017
-
Polyline3d entities exposed only as Drawingelement Use #typename to determine if a Drawingelement is a “Polyline3d”.
↑ #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.
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.