Class: Sketchup::Selection
| Relationships | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Instance Chain:
self,
Enumerable
|
|
| Inherits: | Object |
Overview
A set of the currently selected drawing elements. Use the Model.selection method to get a Selection object. Note that the order of drawing elements (selection[0], selection[1] and so on) in the set is in no particular order and should not be assumed to be in the same order as the user selected the drawing elements.
Instance Attribute Summary
-
#empty? ⇒ Boolean
readonly
The #empty? method is used to determine if there are drawing elements in the selection.
-
#is_curve? ⇒ Boolean
readonly
The #is_curve? method is used to determine if the selection contains all edges that belong to a single curve.
-
#is_surface? ⇒ Boolean
readonly
The #is_surface? method is used to determine if the selection contains only all of the faces that are part of a single curved surface.
-
#single_object? ⇒ Boolean
readonly
The #single_object? method is used to determine if the selection contains a single object.
Instance Method Summary
-
#[](index) ⇒ Sketchup::Drawingelement?
The #[] method is used to retrieve a
Drawingelementfrom the selection by index. -
#add(drawing_elements) ⇒ Integer
The #add method is used to add
Drawingelementto the selection. -
#add_observer(observer) ⇒ Boolean
The add_observer method is used to add an observer to the selection object.
- #at(index) ⇒ Sketchup::Drawingelement?
-
#clear ⇒ nil
The clear method is used to clear the selection.
-
#contains?(drawing_element) ⇒ Boolean
The #contains? method is and alias of #include?.
- #count ⇒ Integer
-
#each {|drawing_element| ... } ⇒ nil
The #each method is used to iterate through all of the selected Drawingelements.
-
#first ⇒ Sketchup::Drawingelement
The #first method is used to retrieve the first selected
Drawingelement. -
#include?(drawing_element) ⇒ Boolean
The #include? method is used to determine if a given
Drawingelementis in the selection. -
#invert ⇒ nil
The #invert method is used to invert the selection.
-
#length ⇒ Integer
The #length method is used to retrieve the number of selected drawing elements.
-
#model ⇒ Sketchup::Model
The #model method retrieves the model for the selection.
- #nitems ⇒ Integer
-
#remove(drawing_elements) ⇒ Integer
The #remove method is used to remove Drawingelements from the selection.
-
#remove_observer(observer) ⇒ Boolean
The remove_observer method is used to remove an observer from the selection object.
-
#shift ⇒ Sketchup::Drawingelement
The #shift method is used to remove the first
Drawingelementfrom the selection and returns it. - #size ⇒ Integer
-
#toggle(drawings_elements) ⇒ Integer
The #toggle method is used to change whether a
Drawingelementis part of the selection.
Instance Attribute Details
#empty? ⇒ Boolean (readonly)
The #empty? method is used to determine if there are drawing elements in the selection.
#is_curve? ⇒ Boolean (readonly)
The #is_curve? method is used to determine if the selection contains all edges that belong to a single curve.
#is_surface? ⇒ Boolean (readonly)
The #is_surface? method is used to determine if the selection contains only all of the faces that are part of a single curved surface.
#single_object? ⇒ Boolean (readonly)
The #single_object? method is used to determine if the selection contains a single object.
It can either be a single DrawingElement or a group of DrawingElements for which is_curve? or is_surface? will return true.
Instance Method Details
#[](index) ⇒ Sketchup::Drawingelement?
The #[] method is used to retrieve a Drawingelement from the selection by index. Index 0 is the first Drawingelement in the selection.
This method is not very efficient. If you need to look at every entity in the selection, consider using #each instead of using this method to manually grab each one.
#add(drawing_elements) ⇒ Integer
#add(*drawing_elements) ⇒ Integer
Integer
#add(*drawing_elements) ⇒ Integer
The #add method is used to add Drawingelement to the selection. Drawingelements that are added to the Selection are visually indicated by the selection bounding box.
You can pass it individual Drawingelements or an ::Array of Drawingelements.
#add_observer(observer) ⇒ Boolean
The add_observer method is used to add an observer to the selection object.
#at(index) ⇒ Sketchup::Drawingelement?
The #at method is an alias for #[].
#clear ⇒ nil
The clear method is used to clear the selection.
#contains?(drawing_element) ⇒ Boolean
The #contains? method is and alias of #include?.
#count ⇒ Integer
Since SketchUp 2014 the count method is inherited from Ruby’s Enumerable mix-in module. Prior to that the #count method is an alias for #length.
#each {|drawing_element| ... } ⇒ nil
Don’t remove content from this collection while iterating over it with #each. This would change the size of the collection and cause elemnts to be skipped as the indices change. Instead copy the current collection to an array using to_a and then use each on the array, when removing content.
The #each method is used to iterate through all of the selected Drawingelements.
If you want to do something with all of the selected Drawingelements, this is more efficient than using #[].
#first ⇒ Sketchup::Drawingelement
The #first method is used to retrieve the first selected Drawingelement
Returns nil if nothing is selected. This method is useful when you know that only a single Drawingelement is selected, or you are only interested in the first selected Drawingelement.
#include?(drawing_element) ⇒ Boolean
The #include? method is used to determine if a given Drawingelement is in the selection.
#invert ⇒ nil
The #invert method is used to invert the selection.
#length ⇒ Integer
The #length method is used to retrieve the number of selected drawing elements.
#model ⇒ Sketchup::Model
The #model method retrieves the model for the selection.
#nitems ⇒ Integer
The #nitems method is an alias for #length.
#remove(drawing_elements) ⇒ Integer
#remove(*drawing_elements) ⇒ Integer
Integer
#remove(*drawing_elements) ⇒ Integer
The #remove method is used to remove Drawingelements from the selection. You can pass it individual Drawingelements or an ::Array of Drawingelements.
#remove_observer(observer) ⇒ Boolean
The remove_observer method is used to remove an observer from the selection object.
#shift ⇒ Sketchup::Drawingelement
The #shift method is used to remove the first Drawingelement from the selection and returns it.
#size ⇒ Integer
The #size method is an alias for #length.
#toggle(drawings_elements) ⇒ Integer
#toggle(*drawing_elements) ⇒ Integer
Integer
#toggle(*drawing_elements) ⇒ Integer
The #toggle method is used to change whether a Drawingelement is part of the selection. Drawingelements that are not already selected are added. Drawingelements that are already selected are removed.
You can pass it individual Drawingelements or an ::Array of Drawingelements.