delete all animation data how to ?

is there a simple way to delete all data for animation
like in the NLA window or the F curves window

may be with a small script to do that quickly ?

thanks

You can clear() the animation data on any object or datablock like so…


def eraseAllKeyframes(scene,passedOB = None):
	if passedOB != None:
		ad = passedOB.animation_data
		if ad != None:
			passedOB.animation_data_clear()
			#scene.update()

does not seems to work !

I dont’ do a lot of anim so not certain what words to use here!
got this for the NLA window
it has a lot of anim things how do u get rid of all these actions ?


and if there are anim F curve for anim objects

will it also get rid of all these curves too ?

use this and does not show anything on console



	
import bpy

def eraseAllKeyframes(scene,passedOB = None):

	if passedOB != None:
	
		ad = passedOB.animation_data
		
		if ad != None:
			print ('ad=',ad)
			passedOB.animation_data_clear()
			#scene.update()


scene = bpy.context.scene

passedOB =  bpy.context.scene.objects.active


eraseAllKeyframes(scene,passedOB = None)


thanks

Try this…


scene = bpy.context.scene
for ob in scene.objects.active:
    eraseAllKeyframes(scene,ob)

eraseAllKeyframes expects a single object, not a list of objects.

Active is the last selected ob if I remember well

modified it and you have to save the file then re open it to see that it has work

this one works



import bpy

def eraseAllKeyframes(scene,passedOB = None):
    
    print ( 'passedOB =  ', passedOB )
    
    if passedOB != None:
    
        print ( 'passedOB =  ', passedOB )
    
        ad = passedOB.animation_data
        
        if ad != None:
            print ('ad=',ad)
            passedOB.animation_data_clear()
            #scene.update()


scene = bpy.context.scene
for ob in bpy.context.scene.objects:

    eraseAllKeyframes(scene,ob)


also save as compress to see difference
I went from 16 MB down to around 3.5 MB!

thanks

does this also remove all F curve for anim too?

thanks

It can be used to remove any datablock type that supports animation_data. You don’t have to pass it an object. You could pass eraseAllKeyframes a material instead. The material type supports animation_data so the data clear will work with that type of object.

the idea was to clear up all the anim data’s some how

so do you need to 2 methods or the first one does all the job too?

would be nice to see the update done with script
no re load to see results !
is it possible ?

thanks