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

    how can i get the id of each target? note: I will add more with c4d.CallButton ()

    Cinema 4D SDK
    python r21 classic api
    3
    3
    495
    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.
    • pyxelriggerP
      pyxelrigger
      last edited by m_adam

      68664532-a8c5-4eb9-9e75-88ea4e2631a6-image.png

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

        Hi,

        the description for this tag is obviously being built dynamically. By poking around in the editor, you can find out that the field Target in the tab Parent is starting at the id 30001 and placed with a stride of 10. So the next ids would be at 30011, 30021, etc.

        To test up to which point your tag has been populated, you should enumerate all possible ids consecutively and test for each if the data container of your tag contains an element of the type BaseLink at that id. When an id fails this test, you know you have reached the end, i.e. the last id in your enumeration was the last valid id. The code could look something like this:

        cid = 30001
        result, data = [], constraint_tag.GetData()
        
        while True:
            if not data.GetType(cid) is c4d.DA_ALIASLINK:
                break
            result.append(cid)
            cid += 10
        

        Cheers,
        zipit

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 1
        • M
          m_adam
          last edited by

          While the method provided by Zipit Is fine, it is not 100% reliable.

          here how to achieve, unfortunately, the ELEMENT_Count value is hardcoded and no way for you to retrieve it.

              constraintTag = doc.GetActiveTag()
              targetCount = constraintTag[c4d.ID_CA_CONSTRAINT_TAG_PARENT_TARGET_COUNT]
              for i in range(targetCount):
                  CONSTRAINT_ELEMENT = 10  # This is hardcoded
                  targetId = c4d.ID_CA_CONSTRAINT_TAG_PARENT_TARGET_COUNT + i * CONSTRAINT_ELEMENT + 1
                  print(constraintTag[targetId])
          

          Cheers,
          Maxime.

          MAXON SDK Specialist

          Development Blog, MAXON Registered Developer

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