TS1234
(TS1234)
1
I tried it - but i was not able to get GLOBAL Z-direction (as vector) from an empty.
some code here… but i can not find a way…
import bpy
o = bpy.data.objects[‘Empty’]
q = o.matrix_world.to_quaternion()
a = q.to_axis_angle()
e = o.matrix_world.to_euler(‘XYZ’)
TS1234
(TS1234)
2
after try and error - i got this:
import bpy
import mathutils
obj = bpy.data.objects['Empty']
mat = obj.matrix_world
pos = mat.translation
zmat = mathutils.Matrix.Translation((0, 0, 1))
mult = mat @ zmat
zpos = mult.translation
delta = zpos - pos
norm = delta.normalized()
print(pos, zpos, delta, norm)