Open Search
    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

    • BaseList2D::GetMarker(): Returns the element's marker.
    • BaseList2D::SetMarker(): Sets the element's marker.
    // 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);
    }
    #define ApplicationOutput(formatString,...)
    Definition: debugdiagnostics.h:204
    const char * doc
    Definition: pyerrors.h:226

    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);
    NONE
    Definition: asset_browser.h:1
    #define MAXON_SOURCE_LOCATION
    Definition: memoryallocationbase.h:69

    See also BaseList2D Marker.

    Allocation/Deallocation

    GeMarker objects can be created with the usual tools:

    • GeMarker::Alloc(): Creates a new GeMarker.
    • GeMarker::Free(): Deletes the given GeMarker.
    // This example creates two markers and checks if they are not equal.
    AutoAlloc<GeMarker> markerA;
    AutoAlloc<GeMarker> markerB;
    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);
    maxon::Bool Bool
    Definition: ge_sys_math.h:46

    Functionality

    GeMarker objects can be handled with:

    • GeMarker::IsPopulated(): Returns true if the GeMarker has been set.
    • GeMarker::IsEqual(): Returns true if the given GeMarker is equal.
    • GeMarker::Compare(): Compares the GeMarker and returns their relationship.
    • GeMarker::Set(): Sets the GeMarker to the value of the given GeMarker.
    • GeMarker::GetMemory(): Retrieves the internally stored data. Typically used to calculate a unique hash value based on that internal data.
    // 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);
    BaseDocument* document = GetFirstDocument();
    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();
    }
    BaseDocument * GetActiveDocument()
    BaseDocument * GetFirstDocument()

    Read and Write

    GeMarker objects can be stored in a HyperFile.

    • GeMarker::Read(): Reads the GeMarker from the given HyperFile.
    • GeMarker::Write(): Stores the GeMarker in the given HyperFile.

    Further Reading