2
$\begingroup$

I'm writing an exporter, and I want to transform an armature to Y-Up coordinates without actually saving it back to the blend file.

So, here's my transformation matrix:

conversionMatrix = axis_conversion(from_forward='Y', from_up='Z', to_forward='Z', to_up='Y').to_4x4()

I get the armature, copy it, and transform it for exporting:

armature = ob.find_armature().copy()
armature.data.transform(conversionMatrix)
# Export...

However, the actual armature in blender is transformed, 90 degrees, which would ruin the model if I were to save the file.

It seems like the armature isn't actually copied. Is there something wrong with what I'm doing?

Blender 2.72b

$\endgroup$
3
$\begingroup$

You copied the armature OBJECT, not the armature data. The copied object referred to the same datablock (armature.data). If you look at the properties panel in the armature tab (as opposed to the object or materials tab) you will see a [2] next to the name of the armature datablock

Instead:

ao = ob.find_armature()
a2 = ao.data.copy()
a2.transform(conversionMatrix)

This copies the armature datablock instead of the object datablock.

$\endgroup$
  • $\begingroup$ Awesome, thank you so much. Do I need to explicitly delete a2 so that the duplicate data block doesn't get saved back into the blend file? $\endgroup$ – winduptoy Nov 8 '14 at 6:50
  • $\begingroup$ I'm reasonably confident that a2 will be garbage collected, although I'm not exactly sure when. The only way it would be preserved is if you give it a fake user (having a fake user is NOT the default). $\endgroup$ – Mutant Bob Nov 11 '14 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.