0
$\begingroup$

How to move object along it's local axis without using operators?

In my case I have objects scattered along curve with Follow Path constraint: example blendfile. Which, I guess, is irrelevant when using matrix_world for applying transformations.

$\endgroup$

2 Answers 2

4
$\begingroup$

Turns out having constraints on object is relevant – cannot use matrix_world for applying transforms. Instead use matrix_basis, to get access to location, rotation and scale, before constraints and parenting are applied.

Following code will move object along its Z axis:

from mathutils import Matrix

loc = Matrix.Translation((0.0, 0.0, 1.5))
ob.matrix_basis @= loc
$\endgroup$
0
$\begingroup$

Just use the location property, which already is in local coordinates.

$\endgroup$
4
  • $\begingroup$ Object's location property displaying local coordinates relative to object's parent, world or constraint, not the object's local coordinates. $\endgroup$ Jun 28, 2017 at 7:45
  • $\begingroup$ "coordinates relative to object's parent" -- that is what "local coordinates" are. The location property is just that. $\endgroup$
    – dr. Sybren
    Jun 28, 2017 at 8:04
  • $\begingroup$ Download example file, select object on curve and change it's Z location, you'll see that it's not moving along object's local Z axis. To move object along it's local axis, you have to switch Manipulator's Transform Orientation to Local. $\endgroup$ Jun 28, 2017 at 8:05
  • 1
    $\begingroup$ I'm sorry, in my first comment I mistakenly used the term "object's local coordinates". What I meant is that object's location property doesn't take into account object's orientation (or local axis). $\endgroup$ Jun 28, 2017 at 8:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .