Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    BaseLink across documents

    Scheduled Pinned Locked Moved Cinema 4D SDK
    c++
    4 Posts 2 Posters 57 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • WickedPW Offline
      WickedP
      last edited by

      Hi Folks,

      Can BaseLink store an object link across documents? I have an object that needs to reference objects in another document (in memory only). Assuming this reference document is open somewhere at the time, will BaseLink achieve this?

      The link needs to work across main scene file opens and close. If not, is there something that can? Couldn't see in docs.

      Trying to plan ahead. Cheers,

      WP.

      wickedp.com

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF Offline
        ferdinand @WickedP
        last edited by ferdinand

        Hey @WickedP,

        Thank you for your question. A BaseLink always requires a document within which it shall be resolved, when you do not provide one, it just takes the active document.

        5a0f8cfd-a94b-4c0f-b3ef-449841104a35-image.png

        So, your question is a bit ambivalent. Internally, a BaseLink is based on GeMarker which identifies a scene element (C4DAtom) over the mac address of the creating machine, the time of creation, and a random UUID. The value is a constant attached to the scene element expressed as 16 bytes of data.

        So, this value is persistent over reload boundaries and does not care for the document it is in - although copying a scene element will usually cause it to get a new marker, unless you tell Cinema 4D explicitly to also copy the marker. You can easily query multiple documents for containing a given C4DAtom via a BaseLink. But unless you deliberately forced markers to be copied, it is not possible that multiple documents contain the same C4DAtom.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • WickedPW Offline
          WickedP
          last edited by

          Thanks @ferdinand.

          When I use LoadDocument in the background, should I also set the NONEWMARKERS flag for scene filters?

          WP.

          wickedp.com

          ferdinandF 1 Reply Last reply Reply Quote 0
          • ferdinandF Offline
            ferdinand @WickedP
            last edited by ferdinand

            Hey @WickedP,

            As I hinted at above, markers are eternally persistent. I.e., you can unload, load, and modify a scene S or the non-cache* node N in it, the node N will always have the same marker.

            The flag you found has a very special purpose and also very misleading documentation (I just fixed that). Each node in a scene must have a unique marker, as otherwise not only BaseLink but also things like undo and more won't work properly when not each node has exactly one marker and each marker exactly one node (i.e., a bijective or 'one-to-one' relation).

            But there can be bad actors such as bugs in our codebase or third party plugins which violate that rule. To combat that, Cinema 4D checks the uniqueness of markers of nodes when a scene is being loaded. When it finds duplicate markers, it will open a question dialog, asking the user if he/she wants to repair that scene. When the user says 'yes', only the nodes which had duplicate markers will get a new marker each (so that they are in a bijective marker relation again).

            This flag you found will suppress this whole behavior, i.e., it will let you load corrupted scenes as is. I would not recommend using it. I am currently not 100% sure what happens when your LoadDocument call is not DIALOGSALLOWED, it looks a bit like that this check then always never runs (which sounds a bit dangerous).

            Cheers,
            Ferdinand

            edit: okay now I see it, the question dialog part has been commented out, so this runs always without asking the user (and with that also without DIALOGSALLOWED), unless you pass the flag NONEWMARKERS.

            [*] Object and other nodes in caches, i.e., the partial scene graph returned by BaseObject::GetCache and generated by ObjectData::GetVirtualObjects, are allocated each time the cache is being built and therefore also have a new marker each time. But you cannot (or better should not) try to build base links, undos, xrefs, etc. for object and other nodes in caches. TLDR: Markers do not work for caches.

            MAXON SDK Specialist
            developers.maxon.net

            1 Reply Last reply Reply Quote 0
            • First post
              Last post