trackview > curve editor > keyframe functions

Hi,

I'm an experienced Maya animator but a newb at Max and Maxscript. I'm trying to translate my favorite mel scripts into maxscript. I've RTFM (read the f*ing manual) on mel and maxscript, and can't find maxscript equivalents of some mel commands. Here is what I'm looking for:

keyframe -an keys -q -keyframeCount;

Mel command that returns an integer for the number of keys you have selected in the graph editor(trackview curve editor in Max). If you've got 20 keys selected in the track view, it returns 20. It doesn't matter what track or what controller they are.

keyframe -q -timeChange;

returns an integer array for the times (in frames) of each selected keyframe in the graph editor.

I have not been able to find a maxscript command that does the same thing.

Basically, I want to be able to select a bunch of keys in the curve editor and find out how many I have selected, then create an array of all of their times (in frames) from earliest to latest.

These two maxscript commands seem like what I should use:

isKeySelected
getKeyTime

...but the problem I'm running into is the controllers. I don't want to have to recursively search through every possible controller that the node could be using, for example:

$.position.controller.x_position.keys
$.position.controller.y_position.keys
etc etc etc

This seems very clunky. Do you guys know of any elegant max commands that are equivalents of those two mel commands?

If I do need to create some function that recursively goes through all the controllers to find the selected keys and their times, I may need some help to understand how that index/matrix system works in maxscript.

Thanks!

Comments

Comment viewing options

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

Hi vindalsaceI don't have

Hi vindalsace

I don't have experience in MEL, but i try to help you...

I think you need looping methode to get/use index
example :

-- Get Key Time of keys currently selected for xyz position
opc = $.position.controller
keytimelist = for i=1 to  (numKeys opc) where ( isKeySelected opc i ) == true collect getKeyTime opc i
keytimelist -- this is key time array collection of keys currently selected 

if you need detail XYZ position separation:

-- Get Key Time of keys currently selected for X position
opcx = $.position.controller.x_position.controller
xkeytimelist = for i=1 to  (numKeys opcx) where ( isKeySelected opcx i ) == true collect getKeyTime opcx i
 
-- Get Key Time of keys currently selected for y position
opcy = $.position.controller.y_position.controller
ykeytimelist = for i=1 to  (numKeys opcy) where ( isKeySelected opcy i ) == true collect getKeyTime opcy i
 
-- Get Key Time of keys currently selected for z position
opcz = $.position.controller.z_position.controller
zkeytimelist = for i=1 to  (numKeys opcz) where ( isKeySelected opcz i ) == true collect getKeyTime opcz i

Regards

Comment viewing options

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