What is the equivalent of setMatrix in blender 2.62?

I am trying to get one of my older python scripts to work in Blender 2.62.

In the old script, I would use setMatrix to apply the rotations I get from an external file containing a 3x3 matrix (mocap kind of…).

Since the changes in the python API, I have not been able to find back this function.

Any hint is welcome, I searched the forum, but maybe I missed the info…

To makes thing more confusing, there is still the function to generate a rotation matrix in mathutils :

create a rotation matrix

mat_rot = mathutils.Matrix.Rotation(math.radians(45.0), 4, ‘X’)

But for the life of me I could not find where this new rotation could be applied to an object in blender…

Hi aws357,

If you simply need to set the world matrix of an object you can use the following code:

import bpy
from mathutils import Matrix
from math import radians

ob = bpy.context.active_object

mat = Matrix.Rotation(radians(45), 4, 'X')

ob.matrix_world = mat

That sets the orientation of the active object by setting the world matrix to the matrix stored in the mat variable. Hope that’s what you’re looking for.


That was helpful, thanks :smiley: