Is it possible to remove one specific animation data instead of clear all by python script?

For example, I have set animations on location and scale properties, and just want to clear animation data for location only keeping scale ones.


2 Answers 2


enter image description here

I have similar situation recently, got thousands of objects and only needing to clear certain channels. I was trying to see if I could find Python script, but apparently Dope Sheet have Summary feature and you can quickly filter out Channels of your selected Object(s) by "Name". So this is super handy as you can search for Scale, and then select all and delete those Scale XYZ channel, or search for X Scale and the summary filter will filter out the X Scale from all selected objects, and then so you can select all from filter and delete those keyframes you don't need.


Came across this question as I was looking for a solution to the same problem. For my Blender needs, deleting keyframes via the Dope Sheet would be quite unwieldy so ended up putting together the following simple Python script to delete animation data of a specific type (location, scale, etc.):

def clear_keyframe(obj, data_path):
        afc = obj.animation_data.action.fcurves
        for fc in afc:
            if fc.data_path == data_path:
                print(f"{obj} {fc} removed")

So you can delete scale animation data like so:

clear_keyframe(obj, 'scale')

insert location or rotation as needed.


You must log in to answer this question.

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