类:Sketchup::Selection
- 继承于:
-
Object
- Object
- Sketchup::Selection
- 包括:
- Enumerable
概述
一组当前选择的实体。使用Model.selection方法来获得一个Selection对象。注意,实体的顺序(selection[0]
,selection[1]
等等)在集合中没有特定的顺序,不应该被认为是与用户选择实体的顺序相同。
实例方法总结# collapse
- #[](index) ⇒ Sketchup::Entity?
-
#add(*args) ⇒ Integer
add方法用于将实体添加到选择中。
-
#add_observer(observer) ⇒ 布尔值
add_observer方法用于向选择对象添加一个观察者。
- #at(index) ⇒ Sketchup::Entity?
-
#clear⇒ nil
清除方法用于清除选择。
-
#contains?(实体) ⇒ Boolean
该#contains?方法的别名是#include?.
- #count⇒ 整数
-
#each{|Sketchup::Entity| ... } ⇒ nil
each方法被用来遍历所有被选中的实体。
-
#empty?⇒ Boolean
empty? 方法用于确定选择中是否有实体。
-
#first⇒ Sketchup::Entity
first方法是用来检索第一个被选中的实体。
- #include?(entity) ⇒ Boolean
-
#invert⇒ nil
该#invert方法是用来反转选择。
-
#is_curve?⇒ Boolean
is_curve?方法用于确定选择是否包含属于一条曲线的所有边。
-
#is_surface?⇒ 布尔值
is_surface?方法用于确定选区是否只包含属于单一曲面的所有面。
-
#长度⇒ 整数
该#length方法是用来检索所选实体的数量。
-
#model⇒ Sketchup::模型
model方法检索了选择的模型。
- #nitems⇒ 整数
-
#remove(*args) ⇒ Integer
remove方法用于从选择中移除实体。
-
#remove_observer(observer) ⇒ 布尔值
remove_observer方法用于从选择对象中移除一个观察者。
-
#shift⇒ Sketchup::Entity
shift方法用于从选择对象中移除第一个实体,并将其返回。
-
#single_object?⇒ Boolean
single_object? 方法用来确定选择是否包含一个单一的对象。
- #size⇒ 整数
-
#toggle(*args) ⇒ Integer
toggle方法是用来改变一个实体是否是选择的一部分。
实例方法细节
↑#[](index) ⇒Sketchup::Entity?
↑ #add(实体) ⇒整数 #add(*entities) ⇒整数
add方法用于将实体添加到选择中。被添加到选区中的实体由选区的边界框直观地表示出来。
你可以传递给它单个的实体或一个实体数组。请注意,添加、删除和切换方法都是彼此的别名。因此,如果你在一个没有被选中的实体上调用移除方法,它将被切换为被选中,而不是被移除。在编写你的代码时要谨慎,不要对一个给定的实体的当前选择状态做出假设。
↑#add_observer(observer) ⇒Boolean
add_observer方法用于将一个观察者添加到选择的对象。
↑#at(index) ⇒Sketchup::Entity?
↑#clear⇒nil
The clear method is used to clear the selection.
↑#contains?(entity) ⇒Boolean
The#contains?method is and alias of#include?.
↑#count⇒Integer
↑#each{|Sketchup::Entity| ... } ⇒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 usingto_a
and then useeach
on the array, when removing content.
The each method is used to iterate through all of the selected entities.
If you want to do something with all of the selected Entities, this is more efficient than using [].
↑#empty?⇒Boolean
The empty? method is used to determine if there are entities in the selection.
↑#first⇒Sketchup::Entity
The first method is used to retrieve the first selected entity
Returns nil if nothing is selected. This method is useful when you know that only a single entity is selected, or you are only interested in the first selected entity.
↑#include?(entity) ⇒Boolean
↑#is_curve?⇒Boolean
The is_curve? method is used to determine if the selection contains all edges that belong to a single curve.
↑#is_surface?⇒Boolean
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.
↑#model⇒Sketchup::Model
The model method retrieves the model for the selection.
↑ #remove(entities) ⇒Integer #remove(*entities) ⇒Integer
The remove method is used to remove entities from the selection.
You can pass it individual Entities or an Array of Entities: Note that the add, remove, and toggle methods are all aliases for one another. So if you call remove on an entity that is not selected, it will be toggled to be selected, not removed! Be cautious when writing your code to not make the assumption about the currently selected state of a given entity.
↑#remove_observer(observer) ⇒Boolean
The remove_observer method is used to remove an observer from the selection object.
↑#shift⇒Sketchup::Entity
The shift method is used to remove the first entity from the selection and returns it.
↑#single_object?⇒Boolean
The single_object? method is used to determine if the selection contains a single object.
It can either be a single Entity or a group of Entities for which is_curve? or is_surface? will return true.
↑ #toggle(entities) ⇒Integer #toggle(*entities) ⇒Integer
The toggle method is used to change whether an entity is part of the selection. Entities that are not already selected are added. Entities that are already selected are removed.
You can pass it individual Entities or an Array of Entities: Note that the add, remove, and toggle methods are all aliases for one another. So if you call remove on an entity that is not selected, it will be toggled to be selected, not removed! Be cautious when writing your code to not make the assumption about the currently selected state of a given entity.