Previous Thread  Next Thread

chat icon How to tell if a bone has Keyframe data

owensm0132

Posted: Mon Oct 22, 2012 9:52 pm
Joined: 22 Oct 2012
Posts: 1
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
Reply with quote


CoDEmanX

Posted: Mon Oct 22, 2012 11:33 pm
Joined: 05 Apr 2009
Posts: 699
maybe like this?

Code:
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...
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group