enter image description here

I'm looking for something similar to this, or other:


1 Answer 1


It seems there is no direct way to get a list of the selected key frames but you can loop through them and check point by point:

for one object and current action :

import bpy

obj = bpy.context.object
action = obj.animation_data.action

for fcurve in action.fcurves :
    for p in fcurve.keyframe_points :
        print(p.co[0], p.select_control_point )

more detailed :

import bpy

obj = bpy.context.object             #active object
action = obj.animation_data.action   #current action

for g in action.groups :
    for channel in g.channels :   # channel is fcurve
        print("  %s[%s] :"%(g.name,channel.array_index))
        for p in channel.keyframe_points :
            print("    is selected at frame %d %s"%(p.co[0], p.select_control_point ))

for the whole scene you cane use :

for action in bpy.data.animation_data.actions :

for the action editor or dopesheet :

import bpy

for area in bpy.context.screen.areas:  #loop through areas
    if area.type == 'DOPESHEET_EDITOR':   #find the dopesheet
        dopesheet = area.spaces[0]
        action = dopesheet.action
        for fcurve in action.fcurves :
            for p in fcurve.keyframe_points :

You must log in to answer this question.

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