Blender API return the same camera position for every rendered frame, when camera is moving along the path

by Brans Ds   Last Updated July 09, 2018 16:15 PM

I have a path and camera following that path. I need to print the camera position for every rendered frame.

cam = bpy.data.objects["Camera"]
s = bpy.context.scene # If your scene is named "Scene", you could also use bpy.data.scenes["Scene"]

for fr in range(s.frame_start, 15):
    print(fr)
    fileName = '/shot_%d.jpg' % fr
    bpy.data.scenes["Scene"].render.filepath = PATH_TO_SAVE + fileName
    s.frame_set(fr)
    #s.frame_current = fr
    s.update()   
    print(cam.location)
    print(cam.rotation_euler)
    bpy.ops.render.render(write_still=True)

Frames rendered pictures are the correct - camera is moving along the path, but cam.location and cam.rotation_euler remains the same during all frames.

<Vector (7.4811, -6.5076, 5.3437)>
<Euler (x=1.4456, y=-0.4655, z=1.9483), order='XYZ'>
<Vector (7.4811, -6.5076, 5.3437)>
<Euler (x=1.4456, y=-0.4655, z=1.9483), order='XYZ'>
<Vector (7.4811, -6.5076, 5.3437)>
<Euler (x=1.4456, y=-0.4655, z=1.9483), order='XYZ'>

How to fix this and get camera position for every rendered frame?



Related Questions



Render animation with different angles

Updated June 05, 2017 03:15 AM


Render points only if visible from another camera

Updated July 15, 2015 16:06 PM