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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    renaming duplicate

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 930 Views
    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.
    • H Offline
      Helper
      last edited by

      On 07/02/2018 at 04:32, xxxxxxxx wrote:

      i have created an object 'Sphere' in my document.
      Then i have created another one and Cinema puts the name "Sphere.1". Thats ok.

      But then i ve been tempted to see if cinema4d allows to rename this second sphere with simply "Sphere" and to my surprise it lets you!

      That puzzles me a bit, because now i have two geometry spheres both with same name!

      if i do:

      mylist = doc.GetObjects()
      for o in mylist:
         print o.GetName()

      it gives be back as result

      Sphere
      Sphere

      Iif i cannot differentiate both objects by name, then how?

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 08/02/2018 at 00:29, xxxxxxxx wrote:

        When inserting new objects the flag "checknames" may help you:
        https://developers.maxon.net/docs/py/2023_2/modules/c4d.documents/BaseDocument/index.html?highlight=insertobject#BaseDocument.InsertObject

        BaseDocument.InsertObject( op [, parent=None , pred=None , checknames=False ])
        _ checknames ( bool ) – Check for duplicate names and append .1, .2 etc.

        _When checking for a unique ID of any BaseList2D, you might want to get the container of the object, via obj.GetData(), then do a container.GetUUid() to check for unique ID's. But i'm not 100% sure, if that's the right and most convinient way to do... others?

        Cheers,
        Lasse
        __

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 08/02/2018 at 03:15, xxxxxxxx wrote:

          Thanks lasse that is what i was looking for!

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 09/02/2018 at 05:21, xxxxxxxx wrote:

            Hi,

            I'm glad you already found a solution.

            Just a few additions from our side:

            As already mentioned in your other thread (custom metadata node), Cinema 4D doesn't care about the names of objects. And the user is always (almost) free to change the names of entities, so I'm not sure these are really good for reference.

            Instead you may want to take a look into GetGUID(). These GUIDs do have their limitations, but in your case might well be an option. Take a look at the thread "Why are GUIDs not globally unique?" for an interesting discussion of the limitations (be aware, though, GeMarker is not available in Python).

            Another option may be the approach discussed in the above mentioned metadata thread. Of course you can store whatever identifier you would want or need in the custom BaseContainer mentioned there.

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