How to retrieve animation key information from 3ds Max?

Hi guys!

I was trying to figure out how to retrieve information from 3ds max animation keys using maxplus, maxscript or the c++ sdk, doesn't matter too much. But I'd like to know which are the specific functions I'd need to use to achieve the goal.

I've tried some of the methods listed in the docs but I haven't had any luck so far.

Let's say I've got a very simple animation of a box:

Where I've created 4 animation keys animating the box position, how would I iterate through these 4 keys and get the info attached to them?

So far I've created this snippet:

    n = MaxPlus.SelectionManager.GetNodes()[0]
    print("n.GetNumKeys()={} n.GetNumSubAnims()={}".format(
        n.GetNumKeys(),
        n.GetNumSubAnims()
    ))
    for index in range(n.GetNumSubAnims()):
        animatable = n.GetSubAnim(index)
        animatable_name = n.GetSubAnim(index)
        if animatable:
            num_keys = animatable.GetNumKeys()
            print("GetSubAnim({})={} num_keys={}".format(index, animatable, num_keys))
        else:
            print("GetSubAnim({})={}".format(index, animatable))

but I don't understand very well the information is giving me:

    n.GetNumKeys()=-1 n.GetNumSubAnims()=7
    GetSubAnim(0)=None
    GetSubAnim(1)=None
    GetSubAnim(2)=Animatable(Position/Rotation/Scale) num_keys=-1
    GetSubAnim(3)=Animatable(Box) num_keys=-1
    GetSubAnim(4)=None
    GetSubAnim(5)=None
    GetSubAnim(6)=None

So, how can I retrieve the information of these 4 keys?

Thanks in advance.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

.

I don't know of what kind of information do you need, but try this and see what is printed in the maxscript listener:

(
	animatedObj = selection[1]
	format "animatedObj.position.controller.keys: % \n" animatedObj.position.controller.keys
	if ( animatedObj.position.controller.keys.count != 0 ) do
	(
		--	"per axis transfer"
		for k in animatedObj.position.x_position.controller.keys do
		(
			format "x_position: % \n"  k		
		)
		for k in animatedObj.position.y_position.controller.keys do
		(
			format "y_position: % \n"  k
		)
		for k in animatedObj.position.z_position.controller.keys do
		(
			format "z_position: % \n"  k
		) 
	)
	--	"Transfer Rotation animation"
	if ( animatedObj.rotation.controller.keys.count != 0 ) do
	(
		format "animatedObj.rotation.controller.keys: % \n" animatedObj.rotation.controller.keys
		--	"per axis transfer"
		for k in animatedObj.rotation.x_rotation.controller.keys do
		(
			format "x_rotation: % \n"  k			
		)
		for k in animatedObj.rotation.y_rotation.controller.keys do
		(
			format "y_rotation: % \n"  k	
		)
		for k in animatedObj.rotation.z_rotation.controller.keys do
		(
			format "z_rotation: % \n"  k	
		) 
	)
	--	"Transfer Scale animation"
	if ( animatedObj.scale.controller.keys.count != 0 ) do
	(
		format "animatedObj.scale.controller.keys: % \n" animatedObj.scale.controller.keys
		for k in animatedObj.scale.controller.keys do
		(
			format "scale: % \n"  k	
		)
	)
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.