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

    Retrieve the newly created object from the "IK_TAG_ADD_GOAL" command?

    Cinema 4D SDK
    r20 python
    2
    5
    987
    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.
    • B
      bentraje
      last edited by

      Hi,

      I have this code that clicks the "Add Goal" in the IK Tag. This creates a null that corresponds to the goal. Is there a way to access this null after creation?

      Currently I have this:

      IKGoal = c4d.CallButton(IKTag, c4d.ID_CA_IK_TAG_ADD_GOAL)
      print(IKGoal)
      
      #returns NONE rather than the Null IK Goal
      
      

      It creates a newly created Null object that represents the IK Goal but when I print(IKGoal), it results to none rather than the Null IK Goal.

      Is there a way around this?

      Thank you for looking at the problem

      1 Reply Last reply Reply Quote 0
      • S
        s_bach
        last edited by

        Hello,

        using CallButton() is the same as pressing the button in the GUI. So the CallButton() function does not return anything.

        The "Add Goal" functionality creates a new Null object. This null object is inserted after the host object of the tag. Sou you could simply get the "next" object to get the goal object.

        tag = doc.GetActiveTag()
        if not tag:
            return
            
        # should check for type of course
        # ...
        
        c4d.CallButton(tag, c4d.ID_CA_IK_TAG_ADD_GOAL)
        
        # assume that the newly created null object is now the next object after the host object
        hostObject = tag.GetObject()
        nextObject = hostObject.GetNext()
        
        print(nextObject)
        

        Alternatively, you could simply read the now defined BaseLink to the goal object:

        c4d.CallButton(tag, c4d.ID_CA_IK_TAG_ADD_GOAL)
        goalObject = tag[c4d.ID_CA_IK_TAG_TARGET]
        

        best wishes,
        Sebastian

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        B 1 Reply Last reply Reply Quote 3
        • B
          bentraje @s_bach
          last edited by

          @s_bach

          Thanks for the revised script Sebastian. I tried both code and it worked as expected.
          But may I ask an additional question:

          Where did you retrieved this: [c4d.ID_CA_IK_TAG_TARGET]?
          I cannot find it in the documentation. It's not also present in the script log. Whenever I modified it, it only appears with a cryptic number: 10001

          I like it because it's descriptive and helps me understand the code better.

          1 Reply Last reply Reply Quote 0
          • S
            s_bach
            last edited by

            Hello,

            you can drag and drop parameters into the Python console. Then you will see the parameter symbol.

            See Python Console.

            Best wishes,
            Sebastian

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

            1 Reply Last reply Reply Quote 2
            • B
              bentraje
              last edited by

              Gotcha. Thanks for clarification!

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