How to tell if a bone has Keyframe data

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

owensm0132
Posts: 1
Joined: Mon Oct 22, 2012 10:47 pm
Location: Lexington, KY

How to tell if a bone has Keyframe data

Postby 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

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

Postby 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 pt.co[0] == KEYFRAME_NUM:
                # found
                break


you may wanna use round(pt.co[0]) instead, as subframes are possible...
I'm sitting, waiting, wishing, building Blender in superstition...


Return to “Python”

Who is online

Users browsing this forum: No registered users and 0 guests