Baking motion across armatures

I’ve had experience with C#, LScript, and a few other languages, but Blender’s Python has me stumped.

I’m trying to bake an Action from a Rigify (IK) armeture, to a copy I’ve made of that armeture where I’ve deleted all but the actual deformation bones and attached the hands to the ends of the arms (FK).

So basically, I need to:

  • Select two Armetures, one as Source the other as Target…
  • Identify all bones with identical names
  • Create a new Action for the Target if desired or clear existing Action
  • Copy (visual?) world-rotation (and world Position for the root bone) from matching Source bones to matching Target bones each frame within a range

I’ve done this in LightWave (but it’s terribly slow), and I’ve worked-out a somewhat tedious method to do this by manually baking/copying F-Curves…

…But trying to automate the process so it can be a simple way for anyone to copy IK animations onto an FK rigging that can then be used by Unity’s Mecanim… I’m stumped.