AtomArray Manual

About

An AtomArray object is used to store multiple pointers to C4DAtom based elements. See C4DAtom Manual.

Access

An AtomArray is typically used to define a selection of scene elements:

See also BaseDocument Selections.

Allocation/Deallocation

An AtomArray object can be created with the usual tools.

Array Elements

Several functions can be used to edit the elements of the array:

// This example creates an AtomArray to get the selected elements of a BaseDocument.
if (selection == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
// 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
{
const BaseList2D* const baseList2d = static_cast<BaseList2D*>(atom);
ApplicationOutput("Name: " + baseList2d->GetName());
}
}

Objects of a certain type can be removed from the array:

// This example gets all selected objects of the given BaseDocument.
// The selection is reduced to point objects.
// get selection
selection->FilterObject(NOTOK, Opoint);
const Int32 objCount = selection->GetCount();
ApplicationOutput("Number of selected point objects: " + String::IntToString(objCount));

Two AtomArray objects can be compared:

Drag and Drop

AtomArray objects are also often used to define arguments of drag and drop operations.

// This example checks the received drag&drop message in a GeDialog.
{
Int32 type = 0;
void* object = nullptr;
// 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
{
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;
}

Copy

AtomArray objects can be copied with:

// This example gets all selected objects of the given BaseDocument.
// The point object selection is copied into a separate AtomArray.
// get selection
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));
}

Further Reading

AtomArray::FilterObject
void FilterObject(Int32 type, Int32 instance, Bool generators=false)
Definition: c4d_baselist.h:1732
BaseList2D
Definition: c4d_baselist.h:2144
DRAGTYPE_ATOMARRAY
@ DRAGTYPE_ATOMARRAY
AtomArray.
Definition: gui.h:759
BFM_DRAGRECEIVE
@ BFM_DRAGRECEIVE
Drag receive. (See DragAndDrop.)
Definition: gui.h:747
BaseDocument::GetSelection
void GetSelection(AtomArray &selection) const
GETACTIVEOBJECTFLAGS::NONE
@ NONE
None.
AtomArray::GetCount
Int32 GetCount() const
Definition: c4d_baselist.h:1619
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:66
Opoint
#define Opoint
Point - PointObject.
Definition: ge_prepass.h:1022
String::IntToString
static String IntToString(Int32 v)
Definition: c4d_string.h:495
BFM_DRAG_FINISHED
@ BFM_DRAG_FINISHED
Bool Drag finished.
Definition: gui.h:770
NOTOK
#define NOTOK
Definition: ge_sys_math.h:265
Tbaselist2d
#define Tbaselist2d
2D list.
Definition: ge_prepass.h:938
BaseDocument::GetActiveObjects
void GetActiveObjects(AtomArray &selection, GETACTIVEOBJECTFLAGS flags) const
C4DAtom
Definition: c4d_baselist.h:1331
MOUSE_COPY
static const Int32 MOUSE_COPY
Copy cursor.
Definition: ge_prepass.h:2486
Int32
maxon::Int32 Int32
Definition: ge_sys_math.h:58
ApplicationOutput
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:207
AtomArray::GetPreferred
C4DAtom * GetPreferred() const
Definition: c4d_baselist.h:1717
AutoAlloc
Definition: ge_autoptr.h:36
C4DAtom::IsInstanceOf
Bool IsInstanceOf(Int32 id) const
Definition: c4d_baselist.h:1373
BaseList2D::GetName
String GetName() const
Definition: c4d_baselist.h:2318
AtomArray::CopyToFilter
Bool CopyToFilter(AtomArray *dest, Int32 type, Int32 instance, Int32 generators=1) const
Definition: c4d_baselist.h:1675
AtomArray
Definition: c4d_baselist.h:1587
BaseContainer::GetInt32
Int32 GetInt32(Int32 id, Int32 preset=0) const
Definition: c4d_basecontainer.h:303
AtomArray::GetUserID
Int32 GetUserID() const
Definition: c4d_baselist.h:1686
AtomArray::GetIndex
C4DAtom * GetIndex(Int32 idx) const
Definition: c4d_baselist.h:1634