Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Unique Object Identifier

    Cinema 4D SDK
    python
    2
    7
    1.5k
    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.
    • M
      Motion4D
      last edited by Motion4D

      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

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

        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.

        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'
        >>> 
        

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • M
          Motion4D
          last edited by

          @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:)

          1 Reply Last reply Reply Quote 0
          • M
            Motion4D
            last edited by

            @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

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

              Hi @Motion4D,

              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.

              Cheers,
              Ferdinand

              MAXON SDK Specialist
              developers.maxon.net

              1 Reply Last reply Reply Quote 0
              • M
                Motion4D
                last edited by

                @zipit thanks for clarifying. Hopefully, there will be something more predictable for IDs in the future.

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

                  Hi @Motion4D,

                  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 😉

                  Cheers,
                  Ferdinand

                  MAXON SDK Specialist
                  developers.maxon.net

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