I'm not that familiar with the structure of Blender's type hierarchy, but according to the documentation for Blender's Object
type there is a distinction between the object and the objects's data block.
# From Blender's Documentation:
# Create new lamp datablock
lamp_data = bpy.data.lamps.new(name="New Lamp", type='POINT')
# Create new object with our lamp datablock
lamp_object = bpy.data.objects.new(name="New Lamp", object_data=lamp_data)
Likewise, bpy.context.scene.camera
is a Blender Object
type which has its camera specific attributes stored in it's data block of Camera
type, which can be accessed with the attribute data
.
camera = bpy.context.scene.camera
camera.data.angle_x = math.radians(69.4) # angle_x and angle_y take radians
The properties panel in the user interface is arranged the same way. Values like location, rotation etc. are set in the Object tab, type specific values like the Field of View of a camera or shape keys for a mesh are set in the Data tab.
You could also have more than one camera in the scene, in which case the cameras could either be accessed as objects in bpy.data.objects['<name>']
(with the camera data accessible from the objects's data attribute again), or you access the data block directly bpy.data.cameras['<name>']
.
bpy.context.scene.camera
would only refer to the active camera of the scene, just like the corresponding entry in the properties panel under the Scene tab.
N.B.: I assume angle_x
and angle_y
can't be set independently but instead are coupled by the aspect ratio. If you set angle_x
, angle_y
will follow suit.