I have 3 joint chains system on my rig:
And I’m trying to write a script which will match FK to IK and vice versa.
In addition to joint chains there are IK and FK curve controls on each of them exept for bound joint chain.
The script will be consist of 4 blocks of code:
1) Control and Attribute names identity check part
I suppose to use long names of controls with retrieving full DAG path because it can be situations where you
will have 2 or more characters in your scene with the same rig and identical control names. The use of unique
namespaces for different characters would be a nice solution as well. I have seen many IKFK match code examples
without identity check at all. I have no idea how they will work for example in complex scenes with a file
referencing and much more than one character onboard.
2) FK -> IK part
Matching FK to IK can be easy – if the joints share the same base orientation, all you need to do is copy the
rotation values from IK joints to their FK counterparts using the xform command. You have to copy
from IK joints to FK joints or FK controls? If copy to FK joints then it is not clear because they already
constrained to FK controls and can not be moved.
3) IK -> FK part
Matching IK to FK is where things get interesting. Technically all you need to do is snap the IK handle to the
FK wrist/foot, and the pole vector to the elbow/knee. Ok this is clear in theory, but what the algorithm in a practice?
The matter is that my IK handle is already parented to the IK control. So it can not be moved or rotated directly in itself.
The same applies to the pole vector it is constrained to my elbowIK control with the Pole Vector Contraint.
4) Set keyframe part
I do not quite understand this part at all. Why you have to key all your controls and IKFK switching attribute
with the setKeyframe command. In what keyframe you have to do this (current or previous)? What if
autoKeyframe option is on/off by the user? And why you should set keyframe with a script if the animator which
will be using your rig can do it manually through the Maya UI?
PS. And in conclusion I have to say that I like TSM2 (The Setup Machine) by Anzovin Studio very much. I wonder
how they are implemented the FKIK snapping because I don’t see any xform or setAttr copying and pasting
rotation values operations in their code. I’ve attached their FKIK MEL script in a case you might be interested in.