Changing an armature's rest pose

Hello,

I have an animated armature whose rest position doesn’t match my model’s position; I’m working on a script to modify the rest position without affecting the animation. Apparently, this has been attempted several times before, with less-than-ideal results.

The idea is to have a functionality similar to the “Apply Pose as Rest Pose” feature, but without changing the armature in any way. The steps are:

  • Get the orientation of each bone in Pose mode, then in Edit mode.
  • Retrieve the difference between the orientations.
  • Apply the resulting rotation in Edit mode.
  • Apply the rotation in Pose mode, once for every frame.

Right now I’m testing with a single bone. Here is my current script:


## This assumes the armature has just been selected
armature = bpy.context.active_object;

## Edit bone orientation
bpy.ops.object.mode_set( mode = 'EDIT' );
editBone = armature.data.edit_bones[0];

qEdit = editBone.matrix.to_quaternion().copy();  # q1

## Pose bone orientation (for the current frame)
bpy.ops.object.mode_set( mode = 'POSE' );
armature.data.pose_position = "POSE";
poseBones = armature.pose.bones;
poseBone = poseBones[0];

qPose = poseBone.matrix.to_quaternion().copy();  # q2


## Difference between orientations
qDif = qEdit.rotation_difference( qPose );

I’m not sure where to go from here. I can’t change the edit bone’s “matrix” property because it’s read-only. I’ve also tried adding this at the end:


matDif = qDif.to_matrix();
editBone.transform( matrix = matDif );

but the second line consistently makes Blender crash for some reason.

This is the method I’m trying right now, but I’m fairly new to Python scripting. If anyone knows an easier way, I’d be very interested.

How can I modify an armature’s rest pose without altering the transformations in its animation?

Thank you, I had seen that thread but I didn’t quite understand everything.

I’m following your directions, but I can’t seem to find the bone snapping utility you mention. I’ve enabled Rigify; where is the option in Blender?

Okay, I think I’m getting it now.

I copied the contents of retarget_pose.py in the Text Editor and ran the script. A number of new options appeared in the Armature menu, and I see the “Snap Bones to Bone” option in the space bar menu.

The only question remaining is how to match the movement between the bones. I have two identical sets of bones inside one armature, and only the first one is animated.

I tried selecting a bone from the second armature, then the same bone from the first, and using Snap Bones to Bone, but I’m getting strange results.

What is the workflow with this utility? (If there’s a tutorial page I simply haven’t found, feel free to link me to it; it’s a little unclear.)

Same with me here, i’ve been follow batFinger post and i am still dont know how its works, may be batFinger can exlplain in a video, that would be very helpfull, u are great but I am confused here,

I hope anyone who understand use batFinger script to repose mocap to T-Pose here can answer my question ?

Thanks to batFinger