c4d.BaseSelect

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.

class c4d.BaseSelect

Members

BaseSelect.__init__()

Initializes a new base selection.

Return type: BaseSelect
Returns: The new base selection.
BaseSelect.GetCount()

Get the number of selected elements.

Return type: int
Returns: The number of selected elements.
BaseSelect.GetSegments()

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.
BaseSelect.IsSelected(num)

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.
BaseSelect.Select(num)

Selects an element.

Parameters: num (int) – The element index to select.
Return type: bool
Returns: True if the element was already selected.
BaseSelect.SelectAll(max[, min=0])

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:
  • max (int) – The last element in the range to select.
  • min (int) – The first element of the select. Default to 0.
Return type:

bool

Returns:

Success of selecting the elements.

BaseSelect.Deselect(num)

Deselects an element.

Parameters: num (int) – The element index to deselect.
Return type: bool
Returns: True if the element was already deselected.
BaseSelect.DeselectAll()

Deselect all elements.

Return type: bool
Returns: Success of deselecting all elements.
BaseSelect.Toggle(num)

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.
BaseSelect.ToggleAll(min[, max])

Toggle the selection state of all elements in the given range.

Parameters:
  • min (int) – The first element to toggle.
  • max (int) – The last element to toggle in the range.
Return type:

bool

Returns:

Success of changing the selection state.

BaseSelect.Merge(src)

Selects all elements that are selected in src.

Parameters: src (BaseSelect) – The source selection object.
Return type: bool
Returns: True if successful, otherwise False.
BaseSelect.DeselectFrom(src)

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.
BaseSelect.GetClone()

Make a duplicate of this selection object with its elements.

Return type: BaseSelect
Returns: The clone object.
BaseSelect.GetDirty()

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.
BaseSelect.CopyTo(dest)

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.
BaseSelect.SetAll(states)

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.
BaseSelect.GetAll(max)

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
BaseSelect.HostAlive()

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.
BaseSelect.Write(hf)

New in version R13.016.

Saves the selection to a file.

Parameters: hf (HyperFile) – The hyperfile to write to.
BaseSelect.Read(hf)

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.
BaseSelect.GetLastElement()

New in version R13.016.

Returns the last element.

Return type: int
Returns: Last element.

Table Of Contents