1
$\begingroup$

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.

$\endgroup$

2 Answers 2

1
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

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):
    try:
        afc = obj.animation_data.action.fcurves
    
        for fc in afc:
            if fc.data_path == data_path:
                afc.remove(fc)
                print(f"{obj} {fc} removed")
    
    except:
        pass

So you can delete scale animation data like so:

clear_keyframe(obj, 'scale')

insert location or rotation as needed.

$\endgroup$

You must log in to answer this question.

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