Maya/Python: SpringIK using Python gives me different result than manual method



As the title says really. Result from this:

  import maya.cmds as mc
    selected =
    mc.ikHandle(sj=selected[0], ee=selected[1], sol='ikSpringSolver',ap=False )

flips the joint chain.

But if I create spring solver manually, (selecting the bones/using mouse), no flipping occurs. Any ideas?

This only happens when I re-orient the original skeleton though. (Aim axis being X, and UP axis being Z)


Take a look at the order of the nodes returned in selected =, and perhaps reorder the items or the indices if they are backwards?


Hmm. I’m fairly new to Python so I would really appreciate it if you could elaborate here.

I checked the list and it is in a correct order:

[u'B_L_Hip_Uppr', u'B_L_Hip_Lowr', u'B_L_Knee', u'B_L_Ankle', u'B_L_ball', u'B_L_Toes']

It seems like it happens only if the last joint selected(before creation of the IK) is ankle, ball or toes. What could be causing this bizarre behavior?

But then again, I just drew a random skeleton without reorienting the chain and tried this script = instant flip


Seems like moving the knee joint a bit forward, fixed the issue but this is hardly a solution. Why is this happening in the first place? If everything works properly using mouse and keyboard, surely Python should do as good of a job if not better…


You might try echoing all commands when you do it manually to see what it is doing from MEL and see if there is a difference between how MEL and Python operate. I have no idea why this might be happening otherwise.


Thanks for the suggestion, but since I’m a scripting newbie, I can’t make sense of echoed commands. I see some familiar lines here and there but that’s it.

I guess there’s just no way to create Spring IK’s using Python.


I know this post is rather old, but I came across the same problem recently and my workaround was to create my IK Handle using the ikRPsolver (which did not move my chain) and then change the solver using:

connectAttr(“ikSpringSolver.message”, “%s.ikSolver” %ik_handle, force = True)

Make sure you source the ikSpringSolver first for that to work.

It fixed the issue on my end, hope it can be of use to someone else in the future :slight_smile: