Class: Sketchup::Entity
- Inherits:
-
Object
- Object
- Sketchup::Entity
- Defined in:
- lib/sketchup-api-stubs/stubs/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, 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.
50 51 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb', line 50 def add_observer(observer) end |
#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.
83 84 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb', line 83 def attribute_dictionaries end |
#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.
120 121 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb', line 120 def attribute_dictionary(name, create = false) 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 #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.
167 168 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb', line 167 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.)
192 193 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb', line 192 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.
218 219 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb', line 218 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.
252 253 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb', line 252 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.
280 281 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb', line 280 def inspect end |
#model ⇒ Sketchup::Model
The model method is used to retrieve the model for the entity.
307 308 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb', line 307 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.
338 339 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb', line 338 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 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”.
396 397 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb', line 396 def persistent_id end |
#remove_observer(observer) ⇒ Boolean
The remove_observer method is used to remove an observer from the current object.
414 415 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb', line 414 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.
457 458 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb', line 457 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.
485 486 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb', line 485 def to_s end |
#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”.
515 516 |
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb', line 515 def typename end |