Get global direction of Z axis

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 =[‘Empty’]
q = o.matrix_world.to_quaternion()
a = q.to_axis_angle()
e = o.matrix_world.to_euler(‘XYZ’)

after try and error - i got this:

import bpy
import mathutils

obj =['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)