Rotate Matrix so that Y is Up

I’m export a mesh for use in some software where Y is up, not Z. This is the code I’ve come up with but honestly I’m not really sure it’s correct. I’m not getting correct results on export and wondering if this is part of the problem.

new_matrix = bone.matrix_local @ Matrix.Rotation(1.5707963267948966, 4, 'Z')

That rotates the Matrix around the Z axis so it changes X and Y. I think you may want to rotate around the X axis so it changes Y and Z.

import math

new_matrix = bone.matrix_local @ Matrix.Rotation(math.pi/2, 4, 'X')
1 Like

Oh of course, I should have seen that. Thanks.