Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Hi, I searched around for an answer on this but I haven't found anything solid on how to identify an object based on a unique ID of any kind in python. Isn't there something uniquely consistent with each object we can refer to? I need something I can write out to a file and read back later to reference a specific object.
Thank you
Hi @Motion4D,
thank you for reaching out to us. The answer to your question is C4DAtom.FindUniqueID. The topic has been discussed just yesterday here and also a couple of times in the past; you might find this thread informative. I also attached a small example, please feel free to come back with any remaining questions.
C4DAtom.FindUniqueID
Happy holidays, Ferdinand
import c4d def main(): """Entry point. """ if op is None: raise RuntimeError("Please select an object") # Get the unique ID attached by MAxon to each node. See linked threads # for details. uuid = op.FindUniqueID(c4d.MAXON_CREATOR_ID) print ("node:", op) print ("uuid:", uuid) print ("raw uuid:", bytes(uuid)) if __name__=='__main__': main()
node: <c4d.BaseObject object called Cube/Cube with ID 5159 at 2488003778176> uuid: <memory at 0x000002434A4CD198> raw uuid: b',\xf0]w\xccG\x14\x0c\xfd\x8c\xfd.\xb8U\x00\x00' >>>
@zipit Hi Ferdinand, yes this is exactly what I was looking for. Sorry, I must have missed the other post. Thanks so much for clarifying with the example code:)
@zipit Hi Ferdinand, it seems I spoke too soon. At first, it seems that the ID stays consistent. But I noticed when you go into the plugin manager and reload a plugin all the IDs change again:( It's possible this won't be an issue for users who aren't reloading plugins but there also may be other things that change the ID of all objects. Is this a bug perhaps or is there really no guarantee that an ID can stay consistent with an object?
Thanks!
Adam
indeed, Cinema does reestablish the scene graph when you hit Reload Python Plugins. However, this is more of an odd outlier, for more details, have a look at this thread I did link to in my first posting, which clarifies a bit the guarantees with which MAXON_CREATOR_ID comes. There has also been a recent thread where we did talk about the shortcomings of unique IDs in regard to caches.
Reload Python Plugins
MAXON_CREATOR_ID
Cheers, Ferdinand
@zipit thanks for clarifying. Hopefully, there will be something more predictable for IDs in the future.
I am not quite sure if there will be anything in the pipeline soon, because the limitations of IDs and markers are more of principal nature due to Cinema's heavily procedural architecture; i.e., not really something that can be "fixed". If you have any particular feature in mind, I would ask you to make a separate post with a dedicated feature request.
We however already did identify the whole "identifying and object"-thing a few weeks ago as something that is probably not explained well enough at the moment and added it to our to-do-list. There are no guarantees on when this will come though