Hi @mastergog,
you can add your own unique IDs, but for that you have to register your own namespace so to speak, a plugin id fed into appid
. What I was proposing was using the already existing IDs in the namespace MAXON_CREATOR_ID
. The advantage here is that Cinema will create them for you
Here is a little script which might give you some context.
Cheers,
Ferdinand
"""Create a bunch of objects and run the script, it will always spit out the
same uuid for the nodes. If you run the script twice in quick succession, it
will probably also spit out the same uuid for the caches. But when you invoke
a rebuild of a cache (by changing the parameter of a parametric object for
example), the uuid of the cache of that object will change.
"""
import c4d
def get_uuid(node):
"""
"""
# A simplified view on caches, we just assume here the top level node
# of GetCache to be "our cache".
cache = node.GetCache()
# Get the unique ids stored under the namespace MAXON_CREATOR_ID for
# the object and its cache.
uuid_0 = bytes(node.FindUniqueID(c4d.MAXON_CREATOR_ID))
if cache is not None:
uuid_1 = bytes(cache.FindUniqueID(c4d.MAXON_CREATOR_ID))
print (node)
# These ids are just CRC-16 codes, so there is nothing really to see
# here, but lets convert them to hex so that we can read them more
# easily.
# This is MAXON_CREATOR_ID for the node itself, it is always there and it
# should be always the same even across reallocation boundaries, including
# reloading a document.
print ("node uuid:", uuid_0.hex())
# This is the cache of the node, it will also contain an MAXON_CREATOR_ID,
# but it will NOT always be the same, since caches can change in "shape
# and form", so there is no way to maintain this continuity.
# I assume this is what you are trying to do, or at least a good part of
# it. This cannot be done, because you are basically asking here the
# caches to be static.
if cache is not None:
print ("cache uuid:", uuid_1.hex())
# The only way I could think of would be some sort of hierarchy dependent
# hashing for the nodes of a cache, i.e. determine the identity of a node
# by its hierarchical relation to the cache root. But this would not be
# really a solution either, because it would also assume caches to be
# hierarchically static, which they are not in many cases.
def main():
"""Will go over all top level object nodes and print their unique ids.
"""
node = op
while node:
get_uuid(node)
node = node.GetNext()
if __name__=='__main__':
main()