# How can I translate an object along its local axis using a script?

I have a cube.

The cube's Z rotation is 45 degrees.

If I press G X X, I can move the object along its local X axis.

How can I do this with a Python script?

## 1 Answer

I found the answer here.

  import bpy
from mathutils import Vector, Matrix

...

trans_local = Vector((0.0, 32.0, 0.0))
trans_world = obj.matrix_world.to_3x3() * trans_local
obj.matrix_world.translation += trans_world

• or simply obj.location += Vector( (32, 0, 0) ) – lemon Sep 3 '16 at 6:38
• @lemon - That's giving me a much different result. Are you sure that that works for local translation? – Pikamander2 Sep 3 '16 at 19:32
• You are right : I have badly read the question – lemon Sep 4 '16 at 5:46