I am currently using blender version 2.92 and am trying to change the camera position using a python script. I am passing the coordinates for the camera using a JSON file and the snippet for the same is as :
"camera_locations":[ [ 2.576395273208618, -4.465750694274902, 1.094475507736206 ], [ 100.87639527320862, -9.465750694274902, 400.094475507736206 ]
I am creating a function and passing the camera object and the camera locations (that I have read from the JSON file ) as parameters. Further, I am then trying to change the camera location and render. Following is the code snippet:
def render(camera_locations,object): camera_location=object.location print("the current camera position is as: ", camera_location) for locations in camera_locations: count=0 for location in locations: object.location[count]=location count+=1 if(count==3): count=0 bpy.context.scene.render.filepath=output_path+str(i) bpy.ops.render.render(use_viewport=True,write_still=True)
However, when I render I do not see any changes in the images with respect to the camera location. The images look identical. I have tried printing the above variables and those do show the updated values. I am not sure what I am missing here. Can someone guide me with this or suggest a better way to tackle the problem?