I want to add a camera from my scene using python. I followed the answer and it created the camera but I am not being able to change the focal length. I even tried using this answer but the focal length remains the same (as default = 50).
def setupCamera(scene, c): pi = math.pi scene.camera.rotation_euler = c * (pi / 180.0) scene.camera.rotation_euler = c * (pi / 180.0) scene.camera.rotation_euler = c * (pi / 180.0) scene.camera.location.x = c scene.camera.location.y = c scene.camera.location.z = c return scene = bpy.data.scenes["Scene"] config = list([69.1, 1.6, 38.9, 7.22, -6.94, 4.95]) bpy.ops.object.camera_add() cam = bpy.data.objects['Camera'] cam.rotation_mode = 'XYZ' scene.camera = cam # Changing focal length bpy.data.cameras.lens = 9.0 setupCamera(scene=scene, c=config)
I have the links to answer but I cannot figure out why the focal length is not being changed to 9.0 ?