GeMarker Manual

About

A GeMarker object contains an unique ID. It is used to identify BaseList2D based objects.

Warning
These markers change when the source object is copied or when the document is re-loaded.

Access

// This example gets the name and the marker of the given BaseObject.
// The name is used to search for an object with the same name in the document.
// The marker is used to check if the found object is also the original object.
const String objectName = object->GetName();
const GeMarker& marker = object->GetMarker();
// search object with the same name
const BaseObject* const foundObject = doc->SearchObject(objectName);
if (foundObject != nullptr)
{
// check if it is the same object
const GeMarker& foundObjectMarker = foundObject->GetMarker();
// compare if the markers are equal
if (foundObjectMarker.Compare(marker) == 0)
ApplicationOutput("The found object is the original object"_s);
else
ApplicationOutput("The found object is not the original object"_s);
}

The marker of a copy is different than the marker of the original object:

// This example copies an object.
// The copy has a different marker than the original.
const GeMarker& originalMarker = object->GetMarker();
C4DAtom* const atomClone = object->GetClone(COPYFLAGS::NONE, nullptr);
BaseObject* const clone = static_cast<BaseObject*>(atomClone);
if (clone == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
doc->InsertObject(clone, nullptr, nullptr);
const GeMarker& cloneMarker = clone->GetMarker();
// check if the markers are not equal
if (cloneMarker.IsEqual(originalMarker) == false)
ApplicationOutput("The markers are not equal"_s);

See also BaseList2D Marker.

Allocation/Deallocation

GeMarker objects can be created with the usual tools:

// This example creates two markers and checks if they are not equal.
const Bool invalidMarkerA = markerA == nullptr;
const Bool invalidMarkerB = markerB == nullptr;
if (invalidMarkerA || invalidMarkerB)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
// compare
if (markerA->IsEqual(*markerB) == false)
ApplicationOutput("Markers not identical"_s);

Functionality

GeMarker objects can be handled with:

// This example iterates through all BaseDocuments in the document list.
// The active BaseDocument is marked with a star.
const BaseDocument* const activeDocument = GetActiveDocument();
if (activeDocument == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
while (document != nullptr)
{
const GeMarker& docMarker = document->GetMarker();
const GeMarker& activeDocMarker = activeDocument->GetMarker();
// use GeMarker to compare identity of the BaseDocuments
if (docMarker.IsEqual(activeDocMarker))
{
ApplicationOutput("Document: " + document->GetDocumentName().GetString() + " *");
}
else
{
ApplicationOutput("Document: " + document->GetDocumentName().GetString());
}
document = document->GetNext();
}

Read and Write

GeMarker objects can be stored in a HyperFile.

Further Reading

GetActiveDocument
BaseDocument * GetActiveDocument(void)
BaseDocument::InsertObject
void InsertObject(BaseObject *op, BaseObject *parent, BaseObject *pred, Bool checknames=false)
BaseDocument::SearchObject
BaseObject * SearchObject(const maxon::String &str)
C4DAtom::GetClone
C4DAtom * GetClone(COPYFLAGS flags, AliasTrans *trn)
Definition: c4d_baselist.h:1411
BaseObject
Definition: c4d_baseobject.h:220
BaseList2D::GetMarker
const GeMarker & GetMarker() const
Definition: c4d_baselist.h:2359
GeMarker::Compare
Int32 Compare(const GeMarker &m) const
Definition: c4d_baselist.h:1288
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:66
GetFirstDocument
BaseDocument * GetFirstDocument(void)
Filename::GetString
String GetString(void) const
GeMarker::IsEqual
Bool IsEqual(const GeMarker &m) const
Definition: c4d_baselist.h:1281
String
Definition: c4d_string.h:35
GeMarker
A unique marker that identifies an object.
Definition: c4d_baselist.h:1250
C4DAtom
Definition: c4d_baselist.h:1325
ApplicationOutput
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:209
AutoAlloc
Definition: ge_autoptr.h:32
Bool
maxon::Bool Bool
Definition: ge_sys_math.h:40
BaseDocument::GetDocumentName
Filename GetDocumentName(void)
BaseDocument::GetNext
BaseDocument * GetNext(void)
Definition: c4d_basedocument.h:516
BaseDocument
Definition: c4d_basedocument.h:479
COPYFLAGS::NONE
@ NONE
None.