Finding First Key

I'm trying to find the keyframe of the first key for a selection of objects.

This is what I have so far and it's chucking up a few errors.
Figured I would get some other eyes on this.

if selection.count >= 1 then
(
	for i=1 to selection.count do
	(
		obj = selection[i]
 
		if obj.controller != undefined and obj.isAnimated then
		(
			getKeyTime obj.controller 1
		)
	)
)

Comments

Comment viewing options

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

Modifier Extrude Amount Keys

Hi i cant make 3dsmax to return the keys on a extrude modifier, how can i do it?

i get keys from position, rotation an scale only?

Thanks

JokerMartini's picture

Modifier

So if both of those scripts find the first key on the transform how do I find the first key on any modifier that could possibly be on the object? Or even the first key on a light multiplier for instance.

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Anubis's picture

Well, just define what you

Well, just define what you want to gather. Looks like you need a function that collect all controllers for the base object transform + it properties + all properties of all modifiers on it ... well, no easy way. 1st need to get all props (see getPropNames mxs function), then check if they has controller, then check if it has keys ...

my recent MAXScripts RSS (archive here)

Anubis's picture

Hi John, obj.isAnimated not

Hi John,
obj.isAnimated not helps here,
need to test if the controller has keys:

obj.controller.keys.count
-- or
numKeys obj.controller

if no keys, both will return -1 ,
and the expression may become...

if selection.count >= 1 do
(
	local keysTime = #()
	for obj in selection do
	(
		if obj.controller != undefined and \
			numKeys obj.controller != -1 do (
			append keysTime (getKeyTime obj.controller 1)
		)
	)
	print keysTime
)

but that still useless 'cause the obj.controller is the transform controller and there no keyable tm-controllers. Next snippet will collect 1st key-time for position controller -

if selection.count >= 1 do
(
	local keysTime = #()
	for obj in selection do
	(
		posTrack = obj[3][1].track -- Transform/Position
		if isController posTrack and \
			numKeys posTrack != -1 do (
			append keysTime (getKeyTime posTrack 1)
		)
	)
	print keysTime
)

my recent MAXScripts RSS (archive here)

Comment viewing options

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