Skip to main content
1 of 2
David
  • 49.7k
  • 40
  • 162
  • 318

Stackoverflow has a similar question and answer on the same issue. The problem is blender is not recalculate the matrix immediately after modifying the transformation.

As mgibsonbr notes, to have the correct values, add scene.update() after the changes to recalculate the matrix.

import bpy
obj = bpy.context.object
print(obj.matrix_world)
obj.location = 1, 2, 3
bpy.context.scene.update()
print(obj.matrix_world)

Which now correctly prints:

<Matrix 4x4 (1.0000, 0.0000, 0.0000, 0.0000)
            (0.0000, 1.0000, 0.0000, 0.0000)
            (0.0000, 0.0000, 1.0000, 0.0000)
            (0.0000, 0.0000, 0.0000, 1.0000)>
<Matrix 4x4 (1.0000, 0.0000, 0.0000, 1.0000)
            (0.0000, 1.0000, 0.0000, 2.0000)
            (0.0000, 0.0000, 1.0000, 3.0000)
            (0.0000, 0.0000, 0.0000, 1.0000)>
David
  • 49.7k
  • 40
  • 162
  • 318