Rotate object on local axis

Hey guys,

For my addon, I’m trying to make an object rotate on in his local axis.
The thing is that the object is not selected.

The object who is rotated serve as reference object and I rotate it in a modal.

To be precise, I work on a circular array.

I create an empty and use it in the array
I launch the modal and I rotate the empty when I change the count.

circular_array_00

If I use Z axis, it’s ok, but I need it to work on every situation, so also when the object is turned on any direction.
And for that, I need to turn my empty in his local axis.

How could I do that in python?

Right now, my code is as simple as that.

empty = modifier[MPM.array_name].offset_object
empty.rotation_euler[2] = radians(float(360 / modifier[MPM.array_name].count))

Thx for your help :wink:

I don’t think this is the right forum for this question, I would suggest blender.stackexchange or blenderartists instead.

Anyway, this is how you can rotate an object around its local Z axis:
object.rotation_euler.rotate_axis("Z", radians(90))

1 Like

I will test, thank you :wink: