Main Index : Reference :

BaseSelect


Description

A selection class.

Definition

class BaseSelect
{
public:
  BaseSelect();

  [bool] Init();

  [bool] Deselect([int] num);
  [bool] Select([int] num);
  [bool] Toggle([int] num);

  [bool] DeselectAll();
  [bool] SelectAll([int] min, [int] max);
  [bool] ToggleAll([int] min, [int] max);

  [bool] IsSelected([int] num);

  [int] GetCount();

  [bool] CopyTo([BaseSelect] dest);
  [BaseSelect] GetClone();
}

Explanation

This class is used to keep track of point and polygon selections. Using a bit array for marking every point either as selected or deselected can be very memory expensive. Imagine having an object with 500.000 points and only 1 point is selected! One would need at least 2 MByte of ram for this array. Instead, CINEMA 4D uses a clever internal compression algorithm to reduce memory size by a factor of 1000 and more. Nevertheless access is very fast.

Members

Init()

[bool] Init();

Resets the selection and all internal cache data. Returns TRUE if successful.


Deselect( num )

[bool] Deselect([int] num);

Deselects element num. Returns TRUE if successful.

Select( num )

[bool] Select([int] num);

Selects element num. Returns TRUE if successful.

Toggle( num )

[bool] Toggle([int] num);

Toggles the selection state of element num. Returns TRUE if successful.


DeselectAll()

[bool] DeselectAll();

Deselects all elements. Returns TRUE if successful.

SelectAll( min, max )

[bool] SelectAll([int] min, [int] max);

Selects all elements from min to max. Returns TRUE if successful.

ToggleAll( min, max )

[bool] ToggleAll([int] min, [int] max);

Toggles the selection state of all elements from min to max. Returns TRUE if successful.


IsSelected( num )

[bool] IsSelected([int] num);

Returns the selection state of element num.


GetCount()

[int] GetCount();

Returns the number of selected elements.


CopyTo( dest )

[bool] CopyTo([BaseSelect] dest);

Copies the selection to dest. Returns TRUE if successful.

GetClone()

[BaseSelect] GetClone();

Returns a copy of the selection.

Example

// Prints all selected points of an object
var obj = doc->FindObject("MyObject");
var select = obj->GetPointSelection();

var i = 0;
var found = 0;

for (i = 0; i < obje->GetPointCount(); i++)
{
  if (found >= select->GetCount()) break;
  if (select->IsSelected(i))
  {
    println(obj->GetPoint(i));
	found++;
  }
}