Unexpected Spline Behavior on Creating IK Spline Tag

  • Hi,

    I'm trying to create an IK Spline Tag with an existing spline/curve object.
    The problem is whenever I run the code, the spline interpolation is replaced.
    You can see an illustration video of the problem here:

    You can check the illustration file here:

    Is there a way around this?

    Thank you for looking at the problem.

    Here is the code I used:

    import c4d
    def list_children(obj, withParent=1):
        if withParent:
            objList = [obj]
            objList = []
        for kid in obj.GetChildren():
            objList += list_children(kid)
        return objList
    def torso_spline():
        spine_chain = list_children(doc.SearchObject("spine01_jnt"))
        start_ikHandle = c4d.BaseObject(c4d.Onull)
        start_ikHandle.SetName( (spine_chain[0].GetName()) + "_ikHandle" )
        end_ikHandle = c4d.BaseObject(c4d.Onull)
        end_ikHandle.SetName( (spine_chain[6].GetName()) + "_ikHandle" )
        spine_crv = doc.SearchObject("spine_crv")
        # Create IK Spline tag
        ikSpline_tag = spine_chain[0].MakeTag(1019862)
        doc.AddUndo(c4d.UNDOTYPE_NEW, ikSpline_tag)
        ikSpline_tag[c4d.ID_CA_IKSPLINE_TAG_SPLINE]    = spine_crv    # error in this. it changes the curve. 
        ikSpline_tag[c4d.ID_CA_IKSPLINE_TAG_END]       = spine_chain[6]
        ikSpline_tag[c4d.ID_CA_IKSPLINE_TAG_TYPE]      = c4d.ID_CA_IKSPLINE_TAG_TYPE_EQUAL
        # Add IK handles
        c4d.CallButton(ikSpline_tag, c4d.ID_CA_IKSPLINE_HANDLE_ADD)
        c4d.CallButton(ikSpline_tag, c4d.ID_CA_IKSPLINE_HANDLE_ADD)
        ikSpline_tag[10002] = start_ikHandle
        ikSpline_tag[10012] = end_ikHandle

  • Kindly ignore the query above.
    I think this is more of a rigging question rather than a coding questing.
    Anyhow, in the IK spline tag, if you set the align and aim axis to X rather than default Z.
    And set the offset from 10cm to like 50cm.

    It should work more or less as expected.


  • Hi @bentraje, since you rotate the axis (with SetMg) you also need to update the tangents according to the correct axis since tangents are in local space of points positions which are also in local space of the object.

    But as you figured is more rigging than a programming issue. And if you already solve the issue congratz! 😉


Log in to reply