BaseLink across documents
-
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.
-
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.

So, your question is a bit ambivalent. Internally, a
BaseLinkis 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
C4DAtomvia aBaseLink. But unless you deliberately forced markers to be copied, it is not possible that multiple documents contain the sameC4DAtom.Cheers,
Ferdinand -
Thanks @ferdinand.
When I use LoadDocument in the background, should I also set the NONEWMARKERS flag for scene filters?
WP.
-
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
BaseLinkbut 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
LoadDocumentcall is notDIALOGSALLOWED, it looks a bit like that this check then always never runs (which sounds a bit dangerous).Cheers,
Ferdinandedit: 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 flagNONEWMARKERS.[*] Object and other nodes in caches, i.e., the partial scene graph returned by
BaseObject::GetCacheand generated byObjectData::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.