I created a script to render images with different came poses with Blender 4.0. But I always get the same image, the camera pose is not updated. I tried with the python interpreter, blender script tab, and with command line. Always same results. I can see the camera being updated in the viewport but it is not taken into account for the rendering. I also tried with the bpy.context.view_layer.update()
but it does not help.
Also I have two layers, but the camera is activated in both. Here is the code:
import bpy
context = bpy.context
cam = context.scene.camera
camera_locations = {
0: (-1.3, 4.3, 2.0),
1: (-1.3, 4.3, 1.0)
}
cam.rotation_euler[0] = 0.0
cam.rotation_euler[1] = 0.0
cam.rotation_euler[2] = 0.0
context.view_layer.update()
for k, v in camera_locations.items():
cam.location[0] = v[0]
cam.location[1] = v[1]
cam.location[2] = v[2]
context.view_layer.update()
bpy.ops.render.render(write_still=True)