Python bone Location/Rotation matching with offest

by MostHost LA   Last Updated May 16, 2019 03:15 AM

I want to copy modifications made on a rigged set of bones over to a second set of bones.

The bones have completely different orientations but seemingly work the same (a rotation is a rotation after-all).

Here is my theory on how to get this done. 1) Get edit bone matrix for rotation. 2) get pose bone matrix for rotaiton. extract repsective euler XYZ, and do math. start - end.

Theoretically, This gives the offset by which every bone in armature B needs to be changed in each pose to match the 2 rigs.

I got this done almost entirely, but then I'm getting lost with the matrix rotations and the Translation.

I can get the bones to move where they should while keeping their current rotation as simple as: boneMove.matrix.translation = Armature.matrix_world * boneFrom.matrix.translation

The moment I try and change the matrix for the bone however, not only do things go wonky (that's the least of my issues since this is a theory) but if I run the code again, I keep getting offset or spinning results, as in the more I click, the more the rotation increments.

Can someone show me how to: Reset the bone position to the position of the original (edit) space via Py Script - Applying the matrix that should be it as translate is not doing anything for me.

Apply a copy of the location of a bone while also adding 45 degree to X, Y and Z

If I can see how that's done I should be able to wrap up my code and go figure out how to properly offset the 2 rigs...

As far as sample code, I attached a 703KB file I was testing with. https://www.dropbox.com/s/gxldxu3kiuy89io/test-bone-py.blend?dl=0



Related Questions


Updated June 09, 2017 11:15 AM

Updated November 24, 2017 01:15 AM

Updated November 22, 2018 16:15 PM

Updated February 22, 2019 20:15 PM

Updated April 08, 2015 18:06 PM