Class: Sketchup::Entity
Relationships | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
ArcCurve, AttributeDictionaries, AttributeDictionary, Axes, Behavior, ComponentDefinition, ComponentInstance, ConstructionLine, ConstructionPoint, Curve, DefinitionList, Dimension, DimensionLinear, DimensionRadial, Drawingelement, Edge, EdgeUse, Face, Group, Image, Layer, LayerFolder, Layers, LineStyle, LineStyles, Loop, Material, Materials, Page, Pages, RenderingOptions, SectionPlane, ShadowInfo, Style, Styles, Text, Texture, Vertex
|
|
Inherits: | Object |
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.
Instance Attribute Summary
-
#deleted? ⇒ Boolean
readonly
The deleted? method is used to determine if your entity is still valid (not deleted by another script, for example.).
-
#valid? ⇒ Boolean
readonly
The #valid? method is used to determine if your entity is still valid (not deleted by another script, for example).
Instance Method Summary
-
#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(dictionary_name) ⇒ Boolean
The #delete_attribute method is used to delete an attribute from an entity.
-
#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 #inspect 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”.
Instance Attribute Details
#deleted? ⇒ Boolean
(readonly)
The deleted? method is used to determine if your entity is still valid (not deleted by another script, for example.)
#valid? ⇒ Boolean
(readonly)
The #valid?
method is used to determine if your entity is still valid (not deleted by another script, for example).
This method is functionally the inverse to the #deleted? method.
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 AttributeDictionary
s.
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
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.
#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.
#inspect ⇒ String
The #inspect
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.
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 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 aDrawingelement
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.
#to_s ⇒ String
The #to_s
method is used to retrieve the string representation of the entity.
#typename ⇒ String
Prefer is_a?
over typename
when possible as it is faster.
The typename method retrieves the type of the entity, which will be a string such as “Face”, “Edge”, or “Group”.