(This is just a basic example). I want to translate, then rotate and then translate again (in local).
At the moment I have this:
import bpy
import mathutils
object = bpy.data.objects["Cube"]
# translate
translation = mathutils.Vector((5.0, 0.0, 0.0))
inv = object.matrix_world.copy()
inv.invert()
vec_rot = translation * inv
object.location = object.location + vec_rot
# rotate
euler = mathutils.Euler((0.0, 0.0, 45.0))
object.rotation_euler.rotate(euler)
# translate again
translation = mathutils.Vector((5.0, 0.0, 0.0))
inv = object.matrix_world.copy()
inv.invert()
vec_rot = translation * inv
object.location = object.location + vec_rot
The problem is that this works as the 2 translates combined followed by the rotate. What I expect is to have the object first move in the x, then rotate, and then move in it's rotated direction.
How can I do this?