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:
- BaseDocument::GetSelection(): Fills the given AtomArray with the selected objects and tags.
- BaseDocument::SetSelection(): Adds the given element to the current selection or starts a new selection.
- BaseDocument::GetActiveObjects(): Returns the current multi-selection of BaseObject objects.
- BaseDocument::GetActivePolygonObjects(): Returns the currently selected polygon objects.
- BaseDocument::GetActiveObjectsFilter(): Returns the currently selected BaseObjects that match the given filters.
- BaseDocument::GetActiveMaterials(): Returns the current multi-selection of BaseMaterial objects.
- BaseDocument::GetActiveTags(): Returns the current multi-selection of BaseTag objects.
See also BaseDocument Selections.
Allocation/Deallocation
An AtomArray object can be created with the usual tools.
- AtomArray::Alloc(): Creates a new AtomArray.
- AtomArray::Free(): Delete the given AtomArray.
Array Elements
Several functions can be used to edit the elements of the array:
- AtomArray::GetCount(): Returns the number of elements in the array.
- AtomArray::GetIndex(): Returns the C4DAtom pointer stored at the given index.
- AtomArray::Append(): Appends a C4DAtom pointer to the array.
- AtomArray::Flush(): Flushes the array. Won't delete the referenced elements.
- AtomArray::Remove(): Removes the given C4DAtom pointer from the array.
- AtomArray::Find(): Returns the index of the given C4DAtom pointer.
AutoAlloc<AtomArray> selection;
if (selection == nullptr)
doc->GetSelection(selection);
for (
Int32 i = 0;
i < selection->GetCount(); ++
i)
{
C4DAtom*
const atom = selection->GetIndex(
i);
{
const BaseList2D*
const baseList2d =
static_cast<BaseList2D*
>(
atom);
}
}
Py_ssize_t i
Definition: abstract.h:645
#define atom
Definition: graminit.h:72
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:69
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
#define Tbaselist2d
2D list.
Definition: ge_prepass.h:995
maxon::Int32 Int32
Definition: ge_sys_math.h:51
const char * doc
Definition: pyerrors.h:226
Objects of a certain type can be removed from the array:
- AtomArray::FilterObject(): Removes object pointers based on the given parameters. See C4DAtom Type.
- AtomArray::FilterObjectChildren(): Removes all objects that have a parent (or ancestor) in the array.
const Int32 objCount = selection->GetCount();
ApplicationOutput(
"Number of selected point objects: " + String::IntToString(objCount));
NONE
Definition: asset_browser.h:1
#define NOTOK
Definition: ge_sys_math.h:258
#define Opoint
Point - PointObject.
Definition: ge_prepass.h:1090
Two AtomArray objects can be compared:
- AtomArray::Compare(): Returns true if the arrays are identical.
Drag and Drop
AtomArray objects are also often used to define arguments of drag and drop operations.
- AtomArray::GetUserID(): Returns the user ID.
- AtomArray::SetUserID(): Sets the user ID.
- AtomArray::GetUserData(): Returns a pointer the user data.
- AtomArray::SetUserData(): Sets the pointer to the user data.
- AtomArray::GetPreferred(): Returns the preferred element.
- AtomArray::SetPreferred(): Sets the preferred element.
{
void* object = nullptr;
GetDragObject(
msg, &
type, &
object);
{
AtomArray*
const dragObjects =
static_cast<AtomArray*
>(
object);
{
if (dragObjects->GetUserID() == 100004709)
for (
Int32 i = 0;
i < dragObjects->GetCount(); ++
i)
{
C4DAtom* draggedAtom = dragObjects->GetIndex(
i);
PrintName(draggedAtom);
}
C4DAtom* preferredAtom = dragObjects->GetPreferred();
PrintName(preferredAtom);
}
else
{
}
}
return false;
break;
}
PyObject * object
Definition: asdl.h:7
@ BFM_DRAG_FINISHED
Bool Drag finished.
Definition: gui.h:797
@ DRAGTYPE_ATOMARRAY
AtomArray.
Definition: gui.h:786
@ BFM_DRAGRECEIVE
Drag receive. (See DragAndDrop.)
Definition: gui.h:774
static const Int32 MOUSE_COPY
Copy cursor.
Definition: ge_prepass.h:2724
PyObject ** type
Definition: pycore_pyerrors.h:34
const char const char * msg
Definition: object.h:438
Copy
AtomArray objects can be copied with:
- AtomArray::CopyTo(): Copies the array into the given AtomArray.
- AtomArray::CopyToFilter(): Copies the array into the given AtomArray while applying the filter arguments.
AutoAlloc<AtomArray> pointObjects;
if (pointObjects == nullptr)
if (selection->CopyToFilter(pointObjects,
NOTOK,
Opoint))
{
const Int32 objCount = pointObjects->GetCount();
ApplicationOutput(
"Number of selected point objects: " + String::IntToString(objCount));
}
Further Reading