[Maya] Using xform On Frozen Objects

Hello,

I’m trying for the first time to do FK IK snapping in Maya using Python and the xform function, unfortunately I’ve frozen the transforms on my IK controls so when I calculate the position of the FK elbow in world space and apply it to my IK pole vector it’s essentially being applied in local space and so it doesn’t work. I’m having a similar problem with matching translation/rotation of the FK hand -> IK hand and vice versa. I had a look on the forums and found a bit of information, but no concrete answers.

For matching the translation of the FK and IK elbow and the rotation of the FK and IK hand, I’m using the following code:


fkElbowTrans = cmds.xform(fkElbow, ws=True, q=True, a=True, t=True)
cmds.xform(ikPv, ws=True, a=True, t=[fkElbowTrans[0], fkElbowTrans[1], fkElbowTrans[2]])

fkHandRot = cmds.xform(fkHand, ws=True, q=True, a=True, rp=True, ro=True)
cmds.xform(ikHand, ws=True, a=True, ro=[fkHandRot[0], fkHandRot[1], fkHandRot[2]])

An obvious solution would be not to freeze the transforms of my animation controls, but I don’t really want to do that, although I had a look at AnimationMentor’s Stewie rig and by default it has non-zero values in its translation and rotation channels.

-Harry

well, if you freeze controls on world children they don’t report their positions in world space anymore - you’ve told them not to. You can get the position by querying the pivot location:


pivpos = cmds.xform("object", q=True, rp=True, ws=True)

Or you can hang a dummy transform off the object and query that transforms world matrix. However you have to watch out for unit translations if you do that, Maya will probably give the matrix back in cm regardless of your unit settings.

I tried a using point and orient constraints (and then deleting them) which seemed to work, but then I recreated my controls and parented them to an empty group that was in the same local space as they were and now everything works fine. I should’ve known to do that from the start, 3ds Max’s freeze transform feature sort of does that by default.