Camera tracker does not output current rotations

Hello,
I would like to report a strange camera parameter issue related to output of rotation vector, if camera is linked by constraint in pointing to object. Probably, this is a bug, or expected, but could somebody help me to fetch updated rotation of a TRACK_TO camera when moved.
Thank you,

A reproduced behaviour could be described as follows:
A scene is designed of one camera and one plane mesh object with name “Plane” (e.g. like in factory reset scene):
Then,
If a “TRACK_TO” constraint is added to a camera such like:
# Python script starts here:
scene = bpy.data.scenes[0]
cam = bpy.data.cameras[0]
camo = bpy.data.objects[cam.name]
scene.camera = camo
camo.select = True
# Let’s print rotation pose of the camera object
print(camo.rotation_euler)
# and location vector:
print(camo.location)
bpy.ops.object.constraint_add(type = ‘TRACK_TO’)
bpy.context.object.constraints[0].track_axis = ‘TRACK_NEGATIVE_Z’
bpy.context.object.constraints[0].up_axis = ‘UP_Y’
bpy.context.object.constraints[0].target = bpy.data.objects[‘Plane’]
camo.location.x = camo.location.x + 5
camo.location.y = camo.location.y - 3
camo.location.z = camo.location.z + 2
# The expected result would be a camera that is always directed to the object “Plane”, but
print(camo.rotation_euler)
# It shows that rotation angles does not change as printed above, but
# location is changed:
print(camo.location)
# Is that a bug?
# Configuration: Blender version - 2.71, PC, Windows 64-bit, NVIDIA 760

camo.matrix_world.to_euler()
gives you the euler rotation after all constraints.

oh, Thank you Florian

I was so desperate that i did my own script to calculate the angles of rotations:

lz = camo.location.z
ly = camo.location.y
lx = camo.location.x

deve = 90*math.pi/180
angle = math.atan(ly/lz)
angleb = math.atan(lx/ly)

if ly>0 and lz>0:
angle = -angle
if ly<0 and lz>0:
angle = -angle
if ly>0 and lz<0:
angle = 2deve-angle
if ly<0 and lz<0:
angle = 2
deve-angle
if lx<0 and ly<0:
angleb = angleb
if lx>0 and ly<0:
angleb = angleb
if lx<0 and lz>0:
angleb = angleb-2deve
if lx>0 and lz>0:
angleb = angleb-2
deve

that works too :slight_smile:
have a look at the mathutils module. there is lots of usefull stuff in there for this kind of work.