Hi

I want rotate object by orientation in python

EX :

Rotate Box Angel 45 at Z

Any help for understand orientation or convert Angel to ran in orientation

# orientation rotate

http://blenderartists.org/forum/showthread.php?t=70111

Orientation (*somewhat*) explained and py examples.

Very useful file and pdf

for me I don’t understand a lot and I didn’t find this

I need to now angle degree and set angel degree only for Z-axis

Thanks

Well, I took this from Herman’s tutorial and added degree conversion. You’ll need to import math:

```
def degrees(alpha,beta,gamma):
rad = math.pi/180
alpha = -alpha * rad
beta = beta * rad
gamma = -gamma * rad
a = math.cos(alpha)
b = math.sin(alpha)
c = math.cos(beta)
d = math.sin(beta)
e = math.cos(gamma)
f = math.sin(gamma)
ad = a*d
bd = b*d
mat = [[c*e, -a*f+b*d*e, b*f+a*d*e],
[c*f, a*e+b*d*f, -b*e+a*d*f],[-d, b*c, a*c]]
return mat
```

use it as

object.setOrientation(degrees(0,0,45))

If you want to do a local setting you have to multiply by the object’s current matrix so you need a multiply matrix function. I also made it so it rotates clockwise in the 7,1,3 views.

That degree conversion looks redundant, doesn’t it? Oh well. It works and 2 of them I made negatives.

edit: added variable rad

ok thanks

this script for set degrees to object

i need one for gat Z degrees from object

There’s a script in Herman’s tutorial for that.