Matching joint positions not working



so i’m trying to match the position and orientation of two joint chains; and IK and FK and for some reason the my Ik wrist just isn’t aligning.

im using this to get the position from the FK

#select the joints we need
sel =

#assign selection
fkWrist = sel[0]
fkShldr = sel[1]
fkuElbow = sel[2]
ikwrist = sel[3]
ikpv = sel[4]

#get positions from fk
fkwRaw = cmds.xform(fkWrist, ws=True, q=True, t=True)
fkwPos = om.MVector(fkwRaw[0], fkwRaw[1], fkwRaw[2])

and to move the Ik wrist into position I am using

#set position of IK wrist ctrl
cmds.move(fkwPos.x, fkwPos.y, fkwPos.z, ikwrist)
cmds.rotate(fkwPos.x, fkwPos.y, fkwPos.z, ikwrist)

Now while I’m still kind of experimenting so I don’t know if the cmds.rotate will give me what I’m looking for, I’m fairly certain that at the very least the cmds.move part should be work properly. I tried having usin my FK joint controls ,the IK wrist controls, and pv as my selections. I also tried using the FK joint controls, the ik handle, and pv as my selections.

After applying script

Before applying script

can anyone help me out here?


I have a couple of cool tools on my shelf for just this purpose:

//Match Position Tool

headsUpMessage “Select Source, then Target…”;

string $selObj[] = ls -sl;

string $ptCsObj[] = pointConstraint -offset 0 0 0 -weight 1 $selObj[1] $selObj[0];

string $findPtCns[] = listRelatives -type pointConstraint $selObj[0];

select $findPtCns; doDelete;

select $selObj[0];

//Match Orientation Tool

headsUpMessage “Select Target then Source!”;

string $selObj[] = ls -sl;

string $ptCsObj[] = orientConstraint -offset 0 0 0 -weight 1 $selObj[1] $selObj[0];

string $findOriCns[] = listRelatives -type orientConstraint $selObj[0];

select $findOriCns; doDelete;

select $selObj[0];

In both cases, select the object you want to move, then the object you want them to match, then hit the button.

What it does is basically creates a point/orient constraint without preserving offsets, then deletes the constraint and leaves the positional data. Works like a charm :slight_smile:


O wow thanks a bunch! unfortunately, this doesn’t seem to be working for me I keep getting syntax error messages


maybe there’s a weird problem with how CGsociety is pasting the code. Here, try just copying these verbatim:


Just for the record, though, you have to make sure you’re using MEL, and not Python. If you’re accidentally using Python it will for sure run errors.

Your script editor text should look like this: