1
$\begingroup$

I have animated a camera, changing the position and FOV between keyframes (see picture below)

I can reach the keyframes related to CameraAction via Python:

>>> len(bpy.context.scene.objects['Camera'].animation_data.action.fcurves)
9

However, the changes to the camera FOV are not included in CameraAction.

How can I reach the FOV keyframes via Python?

enter image description here

$\endgroup$

1 Answer 1

1
$\begingroup$

Animation data aka animation_data are localized where the data are.

For FOV, this is in camera data. You can check:

len(bpy.context.object.data.animation_data.action.fcurves)

Identically, for a mesh, if you had animation data for shape keys (for instance), this is:

bpy.context.object.data.shape_keys.animation_data.action.fcurves
$\endgroup$
4
  • $\begingroup$ unfortunately, the suggestion to use bpy.context.object only works with the current selected object in Blender - which requires an user to click on objects. I am looking for an automated solution where I can loop scene objects and, in this case, discover if they have a FOV change. In addition, this answer does not explain the difference between accessing objects via bpy.context.scene.objects[...] or bpy.context.object - they seem to be different and I do not understand the significance between the two. Simply put; is there a way to refer to my camera object via code instead? $\endgroup$
    – sf033
    Apr 25, 2023 at 16:30
  • $\begingroup$ The question was about finding where is the animation data concerning fov. If your question has other aspects, you should have mentioned it. But, anyway, concerning finding the camera(s), you can loop over `'bpy.data.cameras' which is directly the data part and get the animation data. $\endgroup$
    – lemon
    Apr 25, 2023 at 16:36
  • $\begingroup$ sorry I misunderstood your initial answer. bpy.context.object confused me. I understand now I can access the data via bpy.context.scene.objects['Camera'].data.animation_data.action.fcurves (with a emphasis on .data). The bpy.context.object just means "this current object" and was used as another way to refer to the same object. $\endgroup$
    – sf033
    Apr 25, 2023 at 16:38
  • $\begingroup$ np, and yes, that's it. And looping over all cameras can be done over bpy.data.cameras (which are the "data" parts of the camera objects). $\endgroup$
    – lemon
    Apr 25, 2023 at 16:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .