AtomArray Manual
An AtomArray object is used to store multiple pointers to C4DAtom based elements. See C4DAtom Manual .
An AtomArray is typically used to define a selection of scene elements:
另请参阅 BaseDocument 选择 .
An AtomArray object can be created with the usual tools.
Several functions can be used to edit the elements of the array:
// get selection doc-> GetSelection (selection);
// loop through selected elements for ( Int32 i = 0; i < selection-> GetCount (); ++i) { C4DAtom * const atom = selection-> GetIndex (i); if (atom == nullptr ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION );
// check if the given C4DAtom is a BaseList2D element if (atom-> IsInstanceOf ( Tbaselist2d )) { const BaseList2D * const baseList2d = static_cast< BaseList2D * > (atom); ApplicationOutput ( "Name: " + baseList2d-> GetName ()); } }
Objects of a certain type can be removed from the array:
// get selection doc-> GetActiveObjects (selection, GETACTIVEOBJECTFLAGS::NONE ); selection-> FilterObject ( NOTOK , Opoint ); const Int32 objCount = selection-> GetCount (); ApplicationOutput ( "Number of selected point objects: " + String::IntToString (objCount));
Two AtomArray objects can be compared:
AtomArray objects are also often used to define arguments of drag and drop operations.
// get drag object GetDragObject(msg, &type, & object );
// the object is an AtomArray if (type == DRAGTYPE_ATOMARRAY && object ) { AtomArray * const dragObjects = static_cast< AtomArray * > (object);
// end of drag if (msg. GetInt32 ( BFM_DRAG_FINISHED )) { ApplicationOutput ( ".........." _s);
// check UserID // NOTE: replace ID_OBJECTMANAGER with 100004709 define with real value to get rid of '#include "../../../../resource/modules/newman/c4d_symbols.h"' if (dragObjects-> GetUserID () == 100004709) ApplicationOutput ( "Drag from the Object Manager" _s);
// loop through all dragged objects for ( Int32 i = 0; i < dragObjects-> GetCount (); ++i) { C4DAtom * draggedAtom = dragObjects-> GetIndex (i);
// PrintName() is a custom function PrintName(draggedAtom); }
// get preferred element C4DAtom * preferredAtom = dragObjects-> GetPreferred ();
// PrintName() is a custom function PrintName(preferredAtom); } else { return SetDragDestination( MOUSE_COPY ); } } return false ; break ; }
AtomArray objects can be copied with:
// get selection doc-> GetActiveObjects (selection, GETACTIVEOBJECTFLAGS::NONE ); AutoAlloc<AtomArray> pointObjects; if (pointObjects == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );
// copy the references of all point object into the given AtomArray if (selection-> CopyToFilter (pointObjects, NOTOK , Opoint )) { const Int32 objCount = pointObjects-> GetCount (); ApplicationOutput ( "Number of selected point objects: " + String::IntToString (objCount)); }