ScriptSpot

Forum topic · General Scripting

get highest value in position x ?

By splinterD · 2011-02-04

Description

hi guys

is there a way to get the highest value of position x lets say
from an object that has animation already on x ?

basically im importing a tracked node into max , and it has some crazy position animation baked in .
i need to get the highest value
of x in the entire animation ( or from frame 1 to 100 lets say )
to use in the reaction manger , so i need the value of x .
is there any easy way of getting it with script ? instead of eyeballing it?

thanks

Comments (4)

or...

Anubis · 2011-02-04

collect keys values and get the highest one with amax function:

amax (for k in $[3][1][1].keys collect k.value)

ok

splinterD · 2011-02-05

this is interesting ... "amax" ... never seen it .
ill check it out , thanks allot

br0t · 2011-02-04

You could look at the x position at each frame, store it to an array and sort it afterwards. Something like this:


fn log_position obj=
(
	if obj != undefined do
	(
		local arrX = #()
		local arrY = #()
		local arrZ = #()
		
		sliderTime = animationRange.Start
		for i=animationRange.Start to animationRange.End do
		(
	-- 		print (obj.name + " Position: " + obj.position as String)
			append arrX obj.position.x
			append arrY obj.position.y
			append arrZ obj.position.z
			sliderTime +=1
		)--end for
		
		sort arrX
		sort arrY
		sort arrZ
		
		print ("--- " + selection[1].name + ": ---")
		print ("Highest X Position: " + arrX[1] as string)
		print ("Highest Y Position: " + arrY[1] as string)
		print ("Highest Z Position: " + arrZ[1] as string)
		print "-------------------"
	)--end if
)--end fn

--execute:
log_position selection[1]

Cheers

thanks

splinterD · 2011-02-04

sweet , thanks allot .