Main Index : Reference :

BaseList2D


Description

A bidirectional linked list class.

Definition

class BaseList2D
{
public:
  BaseList2D();
  
  [BaseTrack] GetFirstTrack();
  [bool] InsertTrack([BaseTrack] track, [[BaseTrack] prev]);
  
  [int] GetType();
  [int] GetDiskType();

  [Marker] GetMarker();

  [BaseList2D] GetNext();
  [BaseList2D] GetPrev();

  [bool] InsertBefore([BaseList2D] bl);
  [bool] InsertAfter([BaseList2D] bl);

  [bool] Remove();

  [bool] SetBit([int] bit);
  [bool] GetBit([int] bit);
  [bool] DelBit([int] bit);
  [bool] ToggleBit([int] bit);

  [int] GetAllBits();
  [bool] SetAllBits([int] bits);
  
  [BaseList2D] SearchNext([int] bit);

  [int] GetColor();
  [bool] SetColor([int] col);

  [bool] Message([int] type, [[any type] data = NULL]);
}

Explanation

This is a very essential class for CINEMA 4D. All elements like tags, keys, materials, render settings, documents and so on are derived from BaseList2D, which is a bidirectional linked list. Hence every element is connected with the next and previous element. One can easily navigate within the list using GetNext() or GetPrev() and insert new elements with InsertBefore() or InsertAfter().

Members

GetFirstTrack()

[BaseTrack] GetFirstTrack();

Returns the first animation track of the object, or NULL if there are no tracks.

InsertTrack( track, [prev] )

[bool] InsertTrack([BaseTrack] track, [[BaseTrack] prev = NULL]);

Inserts track into the object's animation track list. Optionally one can specify the insertion position with the prev parameter, giving the track before (just to the left of) the wanted position. Otherwise the track is inserted at the first position in the list. Returns TRUE if successful.


GetType()

[int] GetType();

Returns the type id of the object. This can be used to make sure that a variable really is of the right type before trying to access its members:

if (obj->GetType() != OBJECT_SPLINE) return;

For a list of the possible ids, please see the derived classes. Some objects have the same type id. For example, both position keys and position tracks have the id TRACK_POSITION. If one wants to distinguish between such objects, one can use the instanceof() command:

if (!instanceof(key, PositionKey)) return;

GetDiskType()

[int] GetDiskType();

Returns the object's unique disk type id. Normally this is the same as GetType(), but unlike the normal type id the disk type id is always unique. The disk type is used when saving objects to disk.


GetMarker()

[Marker] GetMarker();

Returns a unique marker that can be used to locate the object during runtime. Markers are only only valid while the program is running.


GetNext()

[BaseList2D] GetNext();

Returns the next object in the linked list, or NULL if this is the last object.

GetPrev()

[BaseList2D] GetPrev();

Returns the previous object in the linked list, or NULL if this is the first object.


InsertBefore( bl )

[bool] InsertBefore([BaseList2D] bl);

Inserts the object before bl in the list that bl is an element in. One must make sure that bl is already attached to a list and that the insertion is sane, i.e. one cannot insert a key into the object list. It is also necessary to use Remove() first if the object is already inserted into another list. Returns TRUE if successful.

InsertAfter( bl )

[bool] InsertAfter([BaseList2D] bl);

Inserts the object after bl in the list that bl is an element in. One must make sure that bl is already attached to a list and that the insertion is sane, i.e. one cannot insert a key into the object list. It is also necessary to use Remove() first if the object is already inserted into another list. Returns TRUE if successful.


Remove()

[bool] Remove();

Removes the object from the list that it's currently attached to. Returns TRUE if successful.


SetBit( bit )

[bool] SetBit([int] bit);

Each object contains a number of flags called bits. This function sets one of the bits, i.e. sets the flag to TRUE. Valid bits are:

Bit Explanation
BIT_ADOC Active document
BIT_AMAT Active material
BIT_ARDATA Active render setting
BIT_ATAG Active tag
BIT_AOBJ Active object
BIT_ADIA Active dia in the browser
BIT_AAMAN Active element in the time line
 
BIT_MATMARK Material used
 
BIT_OFOLD Object folded in the object manager
BIT_AFOLD Object folded in the time line
BIT_TFOLD Track folded in the time line
 
BIT_AAMAN_PX Point selected in space/time curve
BIT_AAMAN_PY
BIT_AAMAN_PZ
 
BIT_AAMAN_LX Left tangent selected in space/time curve
BIT_AAMAN_LY
BIT_AAMAN_LZ
 
BIT_AAMAN_RX Right tangent selected in space/time curve
BIT_AAMAN_RY
BIT_AAMAN_RZ

Returns TRUE if successful.

GetBit( bit )

[bool] GetBit([int] bit);

Returns the state of one of the object's bits. For a list of valid bits, see SetBit(). Returns TRUE if successful.

DelBit( bit )

[bool] DelBit([int] bit);

Deletes one of the object's bits, i.e. sets the corresponding flag to FALSE. For a list of valid bits, see SetBit(). Returns TRUE if successful.

ToggleBit( bit )

[bool] ToggleBit([int] bit);

Toggles the state of one of the object's bits. For a list of valid bits, see SetBit(). Returns TRUE if successful.


GetAllBits()

[int] GetAllBits();

Returns all of the object's bits as an integer. For a list of all bits, see SetBit().

SetAllBits( bits )

[bool] SetAllBits([int] bits);

Sets all of the object's bits at once to the state indicated by bits. For a list of all bits, see SetBit().


SearchNext( bit )

[BaseList2D] SearchNext([int] bit);

Searches for the next element in the list which has bit set and returns it. If no object is found, NULL is returned. Since it is implemented in C, it is much faster than doing it by hand in C.O.F.F.E.E. For a list of all bits, see SetBit().


GetColor()

[int] GetColor();

Returns the color of the object. This is a palette number between 0 and 7, corresponding to one of the eight layers in the timeline.

SetColor( col )

[bool] SetColor([int] col);

Sets the color of the object to col. The parameter should be a palette number between 0 and 7, corresponding to one of the eight layers in the timeline.


Message( type, [data] )

[bool] Message([int] type, [[any type] data = NULL]);

Sends a message to the object. Valid message types are:

Message Explanation
MSG_POINTS_CHANGED The number of points has changed or the points have been
reordered. Include a VariableChanged object as data.
MSG_POLYGONS_CHANGED The number of polygons has changed or the polygons have been
reordered. Include a VariableChanged object as data.
MSG_SEGMENTS_CHANGED The number of segments has changed or the segments have been
reordered. Include a VariableChanged object as data.
MSG_BASECONTAINER Used for custom messages. Include a BaseContainer object as data.
MSG_UPDATE Notify object that something has changed,
for example the position of a point.

To send a message to all objects that are attached to the lists of a BaseDocument or a BaseObject, one can use the function MultiMessage() of each class.

Example

// Inserts a newly created tag after another
var tag = obj->GetFirstTag();
var newTag = new(SmoothingTag);
newTag->InsertAfter(tag);

// Selects a key in the time line
var key = obj->GetFirstTrack()->GetFirstSequence()->GetFirstKey();
key->ToggleBit(BIT_AAMAN, TRUE);
GeEventAdd(TIMELINE_CHANGED);