It’s actually a simple example, but i bet the module scared you off
Here’s how to use it:
add ‘import math’ to the top of your script (Without the ‘’)
now, copy the code for get_rotation into the top of you python file, below all the import statements:
matrix_rotation = object.worldOrientation
euler_rotation = matrix_rotation.to_euler()
degrees_rotation = [math.degrees(a) for a in euler_rotation]
now, wherever you want the rotation of an object calling the function will return the x, y, z rotations.
If you just want the rotation about the Z axis, then do something like this:
z_rotation = get_rotation(object)
or, if you want all 3:
x_rotation, y_rotation, z_rotation = get_rotation(object)
Ah, I was a little late replying
I’m glad you found it useful. If you get into this stuff, feel free to PM me, for I’ll happily explain why that is the case.
The code you’ve extracted is simply in the form of a function above, as you would use a function in maths. It means that if you get the rotation of an object more than once it may prove useful to use a function rather than copying and pasting code each time.