List all keyframes of an action

I’m a bit lost trying to list all the keyframes of an action content.

I’m looking into bpy.data.actions[0].fcurves[0].keyframe_points but I can’t find any keyframe values or even names related to the keyframe.

What should I do to get that?

Thanks!

How to, for example, list the value of each frames of “my_prop” property in this screenshot?


You can either read the keyframe points of fcurves, or evalute fcurves at any desired frame (even subframe):

import bpy

ob = bpy.context.object

if ob is not None:
    if ob.animation_data is not None and ob.animation_data.action is not None:
        action = ob.animation_data.action
        
        print()
        print("Keyframes")
        print("---------")
        for fcu in action.fcurves:
            print()
            print(fcu.data_path, fcu.array_index)
            for kp in fcu.keyframe_points:
                print("  Frame %s: %s" % (kp.co[:]))

        print()
        print("Frames")
        print("------")                
        for fcu in action.fcurves:
            print()
            print(fcu.data_path, fcu.array_index)
            for i in range(1, 6):
                print("  Frame %i: %.6f" % (i, fcu.evaluate(i)))

Thank you very much! :slight_smile: