About
C4DAtom is the base class for many entities in the Cinema API API. Along with GeListNode and BaseList2D it implements the basic functionality of most Cinema API entities. C4DAtomGoal is the extension of the C4DAtom class that allows to create safe references to an C4DAtom entity with a BaseLink.
Access
A pointer to a C4DAtom is typically provided by resolving a BaseLink to an entity. See BaseLink Manual.
- BaseLink::GetLinkAtom(): Evaluates the link and returns a pointer to the linked C4DAtomGoal.
- GeData::GetLinkAtom(): Returns the C4DAtomGoal object referenced by the stored BaseLink object.
GeData data;
const BaseLink* const link = data.GetBaseLink();
if (link == nullptr)
const C4DAtom*
const linkedAtom = link->GetLinkAtom(
doc);
if (linkedAtom != nullptr)
{
}
NONE
Definition: asset_browser.h:1
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:69
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
#define ConstDescID(...)
Definition: lib_description.h:592
@ INSTANCEOBJECT_LINK
Definition: oinstance.h:6
const char * doc
Definition: pyerrors.h:226
C4DAtom pointers to any kind of entity are often stored in AtomArray objects. See AtomArray Manual.
Allocation/Deallocation
C4DAtom instances cannot be created directly. Only instances of C4DAtom based classes can be created.
Type
C4DAtom gives access to information about the type and class of the specific entity:
- C4DAtom::GetClassification(): Returns the classification of the entity. Typical classifications are:
- C4DAtom::IsInstanceOf(): Returns true if the entity is an instance of the given type.
- C4DAtom::GetType(): Returns the type of the entity.
- C4DAtom::GetRealType(): This function is mostly used in conjunction with Xpresso nodes.
- C4DAtom::GetDiskType(): Returns normally the same value as GetClassification(). Typically not used by plugins.
const Int32 classification =
atom->GetClassification();
if (classification ==
Obase)
{
const BaseObject*
const baseObject =
static_cast<BaseObject*
>(
atom);
const Vector position = baseObject->GetMg().off;
{
PointObject*
const pointObject =
static_cast<PointObject*
>(
atom);
const Int32 pointCount = pointObject->GetPointCount();
{
}
}
}
USERINTERACTION
Definition: ge_prepass.h:2
#define atom
Definition: graminit.h:72
#define Offd
FFD.
Definition: ge_prepass.h:1051
#define Opoint
Point - PointObject.
Definition: ge_prepass.h:1090
#define Obase
Base object - BaseObject.
Definition: ge_prepass.h:1089
maxon::Int32 Int32
Definition: ge_sys_math.h:51
void EventAdd(EVENT eventflag=EVENT::NONE)
maxon::Vec3< maxon::Float64, 1 > Vector
Definition: ge_math.h:140
@ FFDOBJECT_SIZE
Definition: offd.h:6
- Note
- C4DAtom::IsInstanceOf() can also be used to check the classification and element type.
-
C4DAtom::GetType() can be used to get the ID of any entity that is not listed in the documentation.
Copy
C4DAtom based entities are easily copied and cloned:
- C4DAtom::CopyTo(): Copies the values of an entity into a given destination entity.
- C4DAtom::GetClone(): Returns a newly allocated clone of the entity.
The copy flags are:
The AliasTrans argument of these functions is optional. If an AliasTrans instance is provided it is used to update BaseLink parameters of the copied entities. If a BaseLink references an element that is also copied the BaseLink is changed to reference the copy of the originally referenced entity.
AutoAlloc<AliasTrans>
alias;
const Int32 selectionCount = objectSelection->GetCount();
if (selectionCount == 0)
for (
Int32 i = 0;
i < selectionCount; ++
i)
{
BaseObject*
const object =
static_cast<BaseObject*
>(objectSelection->GetIndex(
i));
if (object == nullptr)
if (clone == nullptr)
const String objectName = object->GetName();
clone->SetName(objectName + " clone");
doc->InsertObject(clone,
nullptr,
nullptr);
}
#define alias(a0, a1, a2)
Definition: Python-ast.h:681
Py_ssize_t i
Definition: abstract.h:645
Disc I/O
A C4DAtom based element can be read from and written to a HyperFile.
- C4DAtom::Read(): Reads the entity from the given HyperFile.
- C4DAtom::Write(): Writes the entity to the given HyperFile.
If the entity is handled inside another read/write function (NodeData::Read() and NodeData::Write()) these functions must be used:
- C4DAtom::ReadObject(): Reads the entity from the given HyperFile.
- C4DAtom::WriteObject(): Writes the entity to the given HyperFile.
- Warning
- These functions are generally not recommended for third party plugins.
Parameter Properties
Parameter descriptions and IDs are managed with these functions:
- C4DAtom::GetDescription(): Gets the currently used parameter description of the entity. See Description and Description Manual.
- C4DAtom::GetDynamicDescription(): Gets the user data parameter description of the entity. See DynamicDescription and DynamicDescription Manual.
- C4DAtom::GetEnabling(): Returns true if the given parameter is currently enabled.
- C4DAtom::TranslateDescID(): Objects can redirect parameter access with this function. For very generic functionality this function must be called to make sure to handle always the correct parameter and object.
AutoAlloc<Description> description;
if (description == nullptr)
void* handle = description->BrowseInit();
const BaseContainer* bc = nullptr;
DescID id, gid;
while (description->GetNext(handle, &bc, id, gid))
{
}
description->BrowseFree(handle);
@ DESC_NAME
String Name for standalone use.
Definition: lib_description.h:90
Parameters
The value of parameters should be changed with C4DAtom::GetParameter() and C4DAtom::SetParameter(). In this way one can be sure, the parameters are set correctly even if the entity does not store the data in its BaseContainer.
- C4DAtom::GetParameter(): Reads the value of the parameter with the given ID.
- C4DAtom::SetParameter(): Sets the value of the parameter with the given ID.
- Note
- Some parameters must be set with DESCFLAGS_SET::USERINTERACTION.
BaseObject*
const cube =
doc->GetActiveObject();
if (cube ==
nullptr || !cube->IsInstanceOf(
Ocube))
GeData data;
Py_ssize_t size
Definition: bytesobject.h:86
#define Ocube
Cube.
Definition: ge_prepass.h:1118
@ PRIM_CUBE_LEN
Definition: ocube.h:6
- Note
- Parameter IDs are defined with DescID objects. See DescID Manual.
Dirty States
The dirty status of an entity is a number that is increased every time the entity is changed.
- C4DAtom::GetDirty(): Returns the dirty count for the given flags.
- C4DAtom::SetDirty(): Increases the dirty count for the given flags. Mostly used to make a custom plugin class dirty.
The dirty flags are:
baseObject->SetName("New Name"_s);
DATA
Data accessible via Get/SetParameter (including data stored in the BaseContainer and the DIRTYFLAGS::...
Definition: c4d_accessedobjects.h:6
MATRIX
The matrix will be accessed (including e.g. frozen matrix). This doesn't include the global matrix.
Definition: c4d_accessedobjects.h:3
maxon::UInt32 UInt32
Definition: ge_sys_math.h:52
Hierarchy dirty (HDirty) states are used to check if the given entity or some child elements in the hierarchy were changed. Typically used with a BaseDocument or a GeListHead.
- C4DAtom::GetHDirty(): Returns the dirty count for the given flags.
- C4DAtom::SetHDirty(): Increases the dirty count for the given flags. Mostly used to make a custom plugin class dirty.
The hierarchy dirty flags are:
BaseMaterial*
const mat =
doc->GetActiveMaterial();
{
}
MATERIAL
Definition: asset_browser.h:5
#define Mmaterial
Standard material.
Definition: ge_prepass.h:1007
OBJECT
Object mode.
Definition: lib_activeobjectmanager.h:2
@ MATERIAL_COLOR_COLOR
Definition: mmaterial.h:56
Messages
Entities in Cinema 4D often communicate by sending messages to each other. Such a message can be used to inform the element about some event or to retrieve data from the element. A message can be sent to an entity with these functions:
- C4DAtom::Message(): Sends a synchronous message to the entity. Valid message IDs are listed in MSG.
- C4DAtom::MultiMessage(): In case of a GeListNode the message is also sent to the child objects. This is typically used with a BaseDocument.
BaseObject*
const activeObject =
doc->GetActiveObject();
if (activeObject ==
nullptr || !activeObject->IsInstanceOf(
Opoint))
PointObject* const pointObject = static_cast<PointObject*>(activeObject);
Vector*
const points = pointObject->GetPointW();
if (points == nullptr)
const Int32 pointCount = pointObject->GetPointCount();
points[
i] = points[
i] +
Vector(0, 100, 0);
#define MSG_UPDATE
Must be sent if the bounding box has to be recalculated. (Otherwise use MSG_CHANGE....
Definition: c4d_baselist.h:372
See also NodeData::Message() Manual.
Further Reading