Notifications
Clear all

[Closed] animationRange set to last key

Hi,

How can I set the animationRange so that is includes all keys? I want the last frame of the range to be the last animated key.

Thanks

2 Replies

You would have to get all keys for all animated tracks then figure out which is the last one of importance. Then simply assign that value as the end of your animation range. Look up keys, MaxKey, and “Indexed Access to Animatable Properties in 3ds Max Objects” in the Maxscript help for more info.

-Eric

Thanks pixel, that was what I needed to know.

This function will return the time of the last keyed frame.


   	function lastFrameKeyed objs last_frame =
   	(
   		for i in 1 to objs.numSubs do
   		(
   			if(objs[i].keys != undefined) do
   			(
   				k = objs[i].keys
   				if(k.count > 0) do
   				(
   					t = k[k.count].time
   					if(t > last_frame) do 
   						last_frame = t
   				)
   			)
   			if(objs[i].numSubs > 0) then
   			(
   				last_frame = lastFrameKeyed objs[i] last_frame
			)
   		)
   		
   		return last_frame
   	)
   

You call it like this.


   		last_frame = 1
   		for obj in objects do
   		(
   			last_frame = lastFrameKeyed obj last_frame
 		)
   		animationRange = interval 0 last_frame