[3dsmax] Fast way to kill animation?

Hi there,

i am currently looking into ways to remove animation from quite a lot of objects fast. The implementation that is in place currently takes up to 40 minutes or longer for some of our production scenes.

Currently there was a rather naive implementation:


select objects
maxOps.deleteSelectedAnimation()

I have played with various approaches including trackbar filtering to narrow things down etc. The fastest i currently have is this:


ts = timestamp()
deletekeys objects #allkeys
enableSceneRedraw()
)
format "Time: %ms
" (timestamp()-ts)

Now with a test scene i am generating this still takes 139892ms (compared to 207513ms using the current implementation)
Anyone has any ideas how to make that faster? That is still way too slow :frowning: It seems kind of ridiculous to wait over 2 minutes to delete
some animation. From the current numbers i expect that to still be around 15 minutes in production scenes.

Here is the script i use to generate a testcase scene:


(
	seed 0
	delete objects
	smat = Standard()
	cont = Bezier_Float()
	addnewkey cont 50f
	smat.opacity.controller = cont
	
	mmat = MultiMaterial numsubs:2
	mmat[2] = smat
	
	attr = attributes attr 
	(
		parameters params 
		(
			value type:#float
		)
	)
	
	modi = NoiseModifier()
	modi.scale.controller = cont

	text = Noise()
	text.size.controller = cont

	empt = EmptyModifier()
	custattributes.add empt attr
	empt.attr.value.controller = cont
	
	cmat = Standard()
	custattributes.add cmat attr
	cmat.attr.value.controller = cont
	
	mats = #(smat, mmat, Standard diffusemap:text, cmat, Standard(), Standard())
	
	nodes = for k=1 to 5000 do
	(
		b = box()
		if (random 1 10) < 5 do b.mat = mats[random 1 mats.count]
		if (random 1 10) < 3 do b.controller.pos.controller[1].controller = cont
		if (random 1 10) < 2 do addmodifier b modi 
		if (random 1 10) > 8 do addmodifier b empt
		if (random 1 10) > 9 do 
		(
			custattributes.add b attr baseobject:on
			b.baseobject.value.controller = cont
		)
		if (random 1 10) < 2 do 
		(
			custattributes.add b attr baseobject:off
			b.value.controller = cont
		)
		if (random 1 10) > 7 do b.width.controller = cont 
		if (random 1 10) < 1 do 
		(
			converttomesh b
			animatevertex b #all
			addnewkey b.baseobject[#master_point_controller].vertex_1.controller 40f
		)
	)
	gc()
)

Any ideas would be greatly appreciated.

Cheers,
Thorsten

Oh one thing i forgot: If i select all objects manually, select all keys in the timeline and hit “Del”, then the animation is removed within 3 seconds. Any idea how to mimic this behaviour?

Cheers,
Thorsten

Okay, got something that brings substantial gains. In the production scene i am still seeing 3 minutes to remove all animation, but that’s a LOT better than the 30 mins. I am open to other suggestions of course!


(
      fn myCallbackFilterFunction theAnimatable theParent theSubAnimIndex theGrandParent theNode = 
      (           
                  if isController theanimatable and theanimatable.keys.count>0 then
                  (
				deleteKeys theanimatable #allKeys
                        false
                  )
                  else true
      )
      
      with redraw off
      (           
            trackbar.filter = #all
            local filtind = maxops.trackbar.registerFilter myCallbackFilterFunction undefined "." 1 active:on
            select objects
            maxops.trackbar.redraw forceRedraw:on
            maxops.trackbar.unregisterfilter filtind
            clearSelection()
      )
)

Cheers,
Thorsten