How to tell if a bone has Keyframe data

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
Posts: 0
Joined: Mon Oct 22, 2012 10:47 pm
Location: Lexington, KY

How to tell if a bone has Keyframe data

Post by owensm0132 » Mon Oct 22, 2012 10:52 pm

I am working on a remake of the mocap addon and I was wondering if there is a way to tell if a particular bone in an armature has a keyframe at a particular frame. Please forgive me if this question has come up before. Thank you.

Mark Owens

Posts: 0
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Post by CoDEmanX » Tue Oct 23, 2012 12:33 am

maybe like this?

Code: Select all

ob = bpy.context.object
for fcu in ob.animation_data.action.fcurves:
    if fcu.data_path.startswith('pose.bones.["%s"]' % BONE_NAME):
        for pt in fcu.keyframe_points:
            if[0] == KEYFRAME_NUM:
                # found
you may wanna use round([0]) instead, as subframes are possible...
I'm sitting, waiting, wishing, building Blender in superstition...

Post Reply