Class: Sketchup::InstancePath
| Relationships | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Instance Chain:
self,
Enumerable
|
|
| Inherits: | Object |
Overview
The InstancePath class represent the instance path to a given
entity within the model hierarchy.
Class Method Summary
- .new(path) ⇒ Sketchup::InstancePath constructor
Instance Attribute Summary
- #empty? ⇒ Boolean readonly
-
#leaf ⇒ Sketchup::Entity?
rw
The leaf of an instance path is the last element which can be any entity that can be represented in the model.
-
#leaf=(entity)
rw
Sets the leaf entity of the instance path.
-
#valid? ⇒ Boolean
readonly
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.
Instance Method Summary
- #==(other) ⇒ Boolean
-
#[](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.
-
#include?(object) ⇒ Boolean
Returns
trueif the instance path contain the given object. - #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 ⇒ Sketchup::Entity?
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
- #transformation ⇒ Geom::Transformation
Constructor Details
.new(path) ⇒ InstancePath
Instance Attribute Details
#empty? ⇒ Boolean (readonly)
#leaf ⇒ Sketchup::Entity? (rw)
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) (rw)
Sets the leaf entity of the instance path.
#valid? ⇒ Boolean (readonly)
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.
Instance Method Details
#==(other) ⇒ Boolean
#[](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 ⇒ InstancePath
#clone ⇒ InstancePath
Returns a new instance path with the same elements.
#copy(other) ⇒ 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.
#include?(object) ⇒ Boolean
Returns true if the instance path contain the given object.
#length ⇒ Integer
#length is an alias of #size.
#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) ⇒ 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.