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

  • 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)
    #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

  • 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:
    # 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()

    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,

  • @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.

  • Hello,

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

    See Python Console.

    Best wishes,

  • Gotcha. Thanks for clarification!

Log in to reply