3dsmaxmaxscript

Delete all animation Keys using MAXScript in 3ds Max globally


I am trying to use MAXScript to delete all animation Keys from my scene using MAXScript. At the moment I am using the mouse and pressing CTRL + A to select all objects thus bringing up the keys for all objects in my scene. I am then selecting all Keys on the animation timeline using my mouse, and then selecting all keys on the timeline, and then deleting them. How do I do it in MAXScript?

I have found this in the MAXScript documentation, but I don't know how to use it:

deleteKeys <controller> [#allKeys | #selection]  

I tried using

deleteKeys globaltracks #allKeys

but that didn't seem to do anything.


Solution

  • this is a method I posted as part of this challenge on CGTalk. I've modified it to delete all keys on animated controllers. It manipulates the built-in Trackbar custom filter functions to automatically iterate all controllers of all objects, instead of having to retrieve all controllers youself.

    (   
    fn filterCallbackFunction theAnimatable theParent theSubAnimIndex theGrandParent theNode = 
    (       
        if isController theAnimatable do deleteKeys theAnimatable #allKeys
        true
    )
    
    with redraw off
    (   
        trackbar.filter = #all
        local filtind = maxops.trackbar.registerFilter filterCallbackFunction undefined "." 1 active:on
        disableRefMsgs()
        local sel = getCurrentSelection()
        select objects
        maxops.trackbar.redraw forceRedraw:on
        maxops.trackbar.unregisterfilter filtind        
        select sel
        enableRefMsgs()
        ok
    )
    )
    

    Edit: Sorry, or just use this :)

    deleteKeys objects #allKeys