I found a way to point to bones in an armature

import bpy

armature = bpy.data.armatures["Armature"]
for bone in armature.bones:

Here I want to check for names of bones and if those name match then I am looking to remove all the animation from that bone including all Scale , Location and Quaternion Rotation.

Thanks in Advance

  • $\begingroup$ As in same result as using `bpy.ops.anim.keyframe_clear_v3d() in pose mode with selected pose bones? $\endgroup$ – batFINGER May 11 '17 at 15:40
  • $\begingroup$ Actually I am looking for a way to remove animation from body parts of character programmatically like 'limbs' and 'torso' , all this be done just by running the script in the object mode is there a way to point to dope sheet summary ie "W Quaternion Rotation (Neck1)" and also a way to remove them. $\endgroup$ – Shubham Sharma May 11 '17 at 16:16
  • $\begingroup$ I found keyframe_delete(data_path, index=-1, frame=bpy.context.scene.frame_current, group="") but I am not sure how to use it $\endgroup$ – Shubham Sharma May 11 '17 at 17:58

As batFINGER suggested in his comment. This can be done using bpy.ops.anim.keyframe_clear_v3d(). To do this in python you need to select the bone first then apply the operation. Below is a script to delete animation of a specific bone, in this example, a bone named 'Bone' will have its animation deleted:

import bpy

arm = bpy.data.objects['Armature']
arm.select = True
bpy.context.scene.objects.active = arm



for pb in arm.pose.bones:
    if pb.name == 'Bone':
        arm.data.bones[pb.name].select = True
  • $\begingroup$ here I have to select the armature , you know a way by which the armature will get auto selected. Thanks in advance $\endgroup$ – Shubham Sharma May 12 '17 at 15:11
  • $\begingroup$ @ShubhamSharma Answer updated, please mark and accept the answer if it solved your problem. $\endgroup$ – Tak May 12 '17 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.