This class is used to keep track of point and polygon selections. Each method will raise an exception when a host object is established, but not alive anymore.
Initializes a new base selection.
Return type: | BaseSelect |
---|---|
Returns: | The new base selection. |
Get the number of selected elements.
Return type: | int |
---|---|
Returns: | The number of selected elements. |
Get the number of segments that contain elements. For example: the selections 0..4, 6..7, 9..12 would be three segments. This method would return 3 and GetCount() would return 11.
Return type: | int |
---|---|
Returns: | The number of selected segments. |
Get the selection state of an element. If you efficiently want to go through selections you can use the following code:
for index, selected in enumerate(bs.GetAll(maxelements)):
if not selected: continue
pass # index is selected
This is faster than:
for i in xrange(maxelements):
if bs.IsSelected(i):
pass #do something
Parameters: | num (int) – The element index to select. |
---|---|
Return type: | bool |
Returns: | True if the element was already selected. |
Selects an element.
Parameters: | num (int) – The element index to select. |
---|---|
Return type: | bool |
Returns: | True if the element was already selected. |
Selects all elements from in the given range.
Note
All previous selections are cleared.
Here is an example showing how to select all the edges of a PolygonObject:
import c4d
from c4d import utils
def main():
nbr = utils.Neighbor()
nbr.Init(op) # Initialize neighbor with a polygon object
edges = c4d.BaseSelect()
edges.SelectAll(nbr.GetEdgeCount()) # Select all edges in the range [0, nbr.GetEdgeCount()]
op.SetSelectedEdges(nbr, edges, c4d.EDGESELECTIONTYPE_SELECTION) # Select edges from our edges selection
c4d.EventAdd() # Update CINEMA
if __name__=='__main__':
main()
Parameters: |
|
---|---|
Return type: |
bool |
Returns: |
Success of selecting the elements. |
Deselects an element.
Parameters: | num (int) – The element index to deselect. |
---|---|
Return type: | bool |
Returns: | True if the element was already deselected. |
Deselect all elements.
Return type: | bool |
---|---|
Returns: | Success of deselecting all elements. |
Toggles the selection state of an element.
Parameters: | num (int) – The index of the element to toggle. |
---|---|
Return type: | bool |
Returns: | Success of changing the selection state of the element. |
Toggle the selection state of all elements in the given range.
Parameters: |
|
---|---|
Return type: |
bool |
Returns: |
Success of changing the selection state. |
Selects all elements that are selected in src.
Parameters: | src (BaseSelect) – The source selection object. |
---|---|
Return type: | bool |
Returns: | True if successful, otherwise False. |
Deselects all elements that are selected in src.
Note
For C++ developers: This function is redirected to Bool Deselect(const BaseSelect *src)
Parameters: | src (BaseSelect) – The source selection object. |
---|---|
Return type: | bool |
Returns: | True if successful, otherwise False. |
Make a duplicate of this selection object with its elements.
Return type: | BaseSelect |
---|---|
Returns: | The clone object. |
Returns the dirty counter of the selection. This counter is increased every time a function is called that changes the selection.
Return type: | int |
---|---|
Returns: | Dirty counter. |
Copy the selection elements in this selection object to another BaseSelect.
Parameters: | dest (BaseSelect) – The destination selections object. |
---|---|
Return type: | bool |
Returns: | Success of copying the selection elements. |
Set all selected elements from a list. The elements in the list are interpreted as boolean: 0 means the element is unselected, and 1 means it is selected.
Note
The old selection will be completely overridden.
Parameters: | states (list of int) – A list of elements to select. |
---|---|
Return type: | bool |
Returns: | Success of selecting the elements. |
Returns all selected elements in a list.
Parameters: | max (int) – The maximum number of elements to place into the array. |
---|---|
Return type: | list of int |
Returns: | The list |
Returns if the host object is still alive.
Return type: | int |
---|---|
Returns: | 2 if the instance has no host object. Returns 1 if the host object is alive if set and returns 0 if the object is not alive. |
New in version R13.016.
Saves the selection to a file.
Parameters: | hf (HyperFile) – The hyperfile to write to. |
---|
New in version R13.016.
Reads a selection from a file.
Parameters: | hf (HyperFile) – The hyperfile to read from. |
---|---|
Return type: | bool |
Returns: | True if successful, otherwise False. |
New in version R13.016.
Returns the last element.
Return type: | int |
---|---|
Returns: | Last element. |