4

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.

Chendy
  • 175
  • 1
  • 2
  • 6

5 Answers5

3

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
Rotem
  • 21,452
  • 6
  • 62
  • 109
1
max select all
macros.run "Animation Tools" "DeleteSelectedAnimation"
clearSelection()

or drag this code to a toolbar to make a macro!

LoneRobot
  • 26
  • 2
  • Welcome LoneRobot, and thanks for the constructive answer. I would mod up if I would know if it was correct (reviewing first time answers, not an expert on this). – Maarten Bodewes May 07 '12 at 23:14
1

OR to just delete keys from a limited group of objects try

for o in objects where matchpattern o.name pattern:"*somename*" do deleteKeys o #allKeys

or select the objects to delete keys from and try this

for o in selection do deletekeys o #allkeys
dave tyner
  • 11
  • 1
1

I used to delete all keys using this command:

deletekeys $*.controller #allkeys
Mikaël Mayer
  • 10,425
  • 6
  • 64
  • 101
  • How can I use this on camera&cameraTarget? – Dariusz Jan 23 '17 at 14:45
  • `deletekeys camera.controller #allkeys` ? Could also be something like `deletekeys camera.position.controller #allkeys` but its has been a while since I did not touch 3ds max. – Mikaël Mayer Jan 24 '17 at 10:00
0

Without scripting: Hit Ctrl-A, then Main Menu > Animation > Delete selected animation

Martin
  • 9
  • 1