Class: Sketchup::InstancePath
- Inherits:
-
Object
- Object
- Sketchup::InstancePath
- Includes:
- Enumerable
Overview
The InstancePath class represent the instance path to a given entity within the model hierarchy.
Instance Method Summary # collapse
-
#==(other) ⇒ Boolean
`true` if the instances paths represent the same set of entities.
-
#[](index) ⇒ Sketchup::Entity
The elements of an instance path can be accessed similarly to an array.
-
#clear ⇒ Sketchup::InstancePath
Clears the instance path.
-
#clone ⇒ Sketchup::InstancePath
Returns a new instance path with the same elements.
-
#copy(other) ⇒ Sketchup::InstancePath
Copies all elements from another instance path into this one.
-
#each {|entity| ... } ⇒ nil
The yielded entities will start with the root and end with the leaf.
- #empty? ⇒ Boolean
-
#include?(object) ⇒ Boolean
Returns `true` if the instance path contain the given object.
- #initialize(path) ⇒ Sketchup::InstancePath constructor
-
#leaf ⇒ Sketchup::Entity?
The leaf of an instance path is the last element which can be any entity that can be represented in the model.
-
#leaf=(entity) ⇒ Object
Sets the leaf entity of the instance path.
- #length ⇒ Integer
-
#persistent_id_path ⇒ String
The serialized version of an instance path is the persistent ids of its entities concatenated with a period.
-
#pop(*args) ⇒ Object
Removes items from the end in-place.
-
#push(entity) ⇒ Sketchup::InstancePath
Appends the given entity to the path in-place.
-
#root ⇒ Sketchup::Group, ...
The root of an instance path is the element located closest to the model root.
- #size ⇒ Integer
-
#to_a ⇒ Array
An array representing the instance path.
- #transformation(*args) ⇒ Object
-
#valid? ⇒ Boolean
An instance path is valid if it has at least one element and consist of groups and instances with exception of the leaf which can be any entity.
Constructor Details
↑ #initialize(path) ⇒ Sketchup::InstancePath
Instance Method Details
↑ #==(other) ⇒ Boolean
Returns `true` if the instances paths represent the same set of entities.
↑ #[](index) ⇒ Sketchup::Entity
This method does not accept negative indices. For the exact behavior of an array, use {#to_a}.
The elements of an instance path can be accessed similarly to an array.
↑ #clear ⇒ Sketchup::InstancePath
↑ #clone ⇒ Sketchup::InstancePath
Returns a new instance path with the same elements.
↑ #copy(other) ⇒ Sketchup::InstancePath
Copies all elements from another instance path into this one.
↑ #each {|entity| ... } ⇒ nil
The yielded entities will start with the root and end with the leaf.
↑ #empty? ⇒ Boolean
↑ #include?(object) ⇒ Boolean
Returns `true` if the instance path contain the given object.
↑ #leaf ⇒ Sketchup::Entity?
The leaf of an instance path is the last element which can be any entity that can be represented in the model. This is normally a Drawingelement, but could be a Vertex.
An instance can also be a leaf.
↑ #leaf=(entity) ⇒ Object
Sets the leaf entity of the instance path.
↑ #persistent_id_path ⇒ String
The serialized version of an instance path is the persistent ids of its entities concatenated with a period.
↑ #pop ⇒ Sketchup::Entity? #pop(num) ⇒ Array<Sketchup::Entity>
If num is 0, no elements are removed. If num is greater than the path length, all elements are removed.
Removes items from the end in-place.
This treats the path as a flat list and removes items from the end, whether they are instances or a leaf.
↑ #push(entity) ⇒ Sketchup::InstancePath
This method modifies the path in-place. Use #clone if you want to keep the original path unchanged.
Appends the given entity to the path in-place.
This treats the path as a flat list and appends the entity to the end. The entity can be an instance (group, component instance, image) or a leaf entity.
↑ #root ⇒ Sketchup::Group, ...
The root of an instance path is the element located closest to the model root. This will be a group or component instance. If you have a non-instance as a leaf with no other parent component this will return `nil`.
↑ #size ⇒ Integer
↑ #transformation ⇒ Geom::Transformation #transformation(index) ⇒ Geom::Transformation
↑ #valid? ⇒ Boolean
An instance path is valid if it has at least one element and consist of groups and instances with exception of the leaf which can be any entity.
This method doesn't check if the path can actually be looked up in the model.