ScriptSpot

Forum topic · General Scripting

Finding First Key

By JokerMartini · 2011-02-23

Description

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 (4)

Modifier Extrude Amount Keys

pfbelesa · 2016-01-18

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

Modifier

JokerMartini · 2011-02-23

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.

Anubis · 2011-02-23

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 ...

Anubis · 2011-02-23

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
)