IK-FK Matching Theory

This is not a tutorial. IK/FK matching is an advanced subject, required a good degree of knowledge & comfort with both rigging and scripting. It’s a topic that, if you don’t yet have the necessary skill level, a tutorial may not be enough. But if you DO have the proper skill level, then you should be capable of figuring it out on your own, and thus wouldn’t need a tutorial.
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 the IK joints to their FK counterparts. I recommend using the xform command, instead of getAttr, as it’s more versatile, and allows us to copy and paste rotation values in either local or world space. If your joint chains don’t share the same orientation, then you’ll need to match to reference transforms – empty groups attached to the IK joints, that share the FK joints’ orientation.
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. But you may not want the pole vector to be directly on the joint, and moving it without changing the pose can be a pain. The easiest thing to do mit be to temporarily orient-constrain the pole vector control between the upper and lower FK bones. This way, it should be possible to move the pole vector straight out from the hinge in local-space, without affecting the pose. Automating this with a script is a little more difficult, because the script will need to determine which axis to move the object along. You could hard-code the axis into the script, but that will cause problems when you use it on a character whose controls don’t have the same orientations.
Knowing how to match these two chains isn’t much use, if you don’t also know how to script it. The trick here is you either need to build your rigs with the matching procedure in mind, or write custom procedures for each rig. Building the rigs to fit the script is preferred, but occasionally you’ll run into rigs that aren’t built to the same standards as others, and may not work correctly (or at all). When this happens, you could update the script and risk breaking it, or write a new script just for that rig. Or you could berate the rigger for not using the same standards as the rest of the team. Those standards could change from one project to the next, though, so be prepared to update or rewrite the script for each project.
With a script in place, you then need to decide how you’re going to use it. It’s not very intuitive to have to type the command each time. The easiest approach is to type the commands for each limb, and drag them to a shelf. Or, if you have a character picker GUI, you could attach the matching commands to buttons there. A more advanced method is to create a scriptJob that loads and unloads with the scene, that will run the matching script whenever a specific attribute on, say, the IK Handle is changed. Some rigs go even further by including a right-click command, but this involves hacking one of Maya’s core script files.
In conclusion, IK/FK matching is not the easiest feature to implement… But if you CAN implement it, your animators will love you for it.