Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   Keyframe mel (https://simplymaya.com/forum/showthread.php?t=20960)

Velusion 05-04-2006 04:56 PM

Keyframe mel
 
I'm going to write a script that will be a great tool for animators but I could use a little guidance. Here's what I'm trying to do:

Imagine you're animating a character. Now, you're on frame 100 and you decide you want to turn the character's head. So, you turn its head BUT you are obligated to set a keyframe before frame 100 to serve as the start of the turn. Instead of going back in the timeline, wouldn't it be great if you could hit a button on a gui that would automatically set the keyframe for you. The gui could have a slider that allows you to set the number of frames back in time that the keyframe would be set. There could also be check boxes so you could tell it to set Trans X,Y,Z or Rot X,Y,Z.

I'm not trying to get anyone to write this script for me but if someone could point me toward the MEL commands that would most useful for this, I'd appreciate it. I'm not worried about the gui. I'm more concerned with the commands for going back in time and setting the keys.

Thanks a bunch!

skywola 05-04-2006 05:56 PM

That's a great idea, I have some code in my Walkerman project that keyframes using MEL.

//Set KeyFrame

string $c = "setKeyframe " + $attr;

button -label "K" -annotation "Set Keyframe" -command $c;

// cut Keyframe

string $c = "cutKey -cl -t `currentTime -q` " + $attr;

button -label "U" -annotation "Cut Key" -command $c;


Would need to find a way to choose the frame being keyed, or temporarily change the frame back to the key point, key, then return.

I don't have the time now to do much more than post an example from the code I wrote, but I will take a look at it when I have more time this weekend. . .

Velusion 05-04-2006 08:59 PM

Much appreciated skywola.

I came up with this idea while animating since I am always forgetting to set a keyframe before repositioniing the model. All of a sudden you're scrubbing the timeline wondering why the models hand is going up and its head is turning :)

skywola 06-04-2006 07:40 AM

This one may be a little tricky because you would need to remember *NOT* to turn the head before you hit the "retro-key" button.

Perhaps a good solution would be have the code check for a keyframe occurence previous to the one you are attempting to place, then in the code, if there is none, have it set the pre-keyframe for the attribute you are attempting to set before it actually sets the one you are attempting to set.

Velusion 06-04-2006 12:39 PM

That's a very good idea.

skywola 06-04-2006 01:02 PM

I know there is a way that Maya checks for previous keyframes, because you can actually click on a button next to the play buttons that will jump to the next or previous keyframes.

Turning "echo all commands" on, in the script editor gives me:

currentTime -edit `findKeyframe -timeSlider -which previous`;

when I click the go to previous key button . . .

That is probably a good hint on the direction you would want to go when writing the code to find if there is a previous keyframe.

vladimirjp 06-04-2006 02:32 PM

Re: Keyframe mel
 
Quote:

Originally posted by Velusion


Imagine you're animating a character. Now, you're on frame 100 and you decide you want to turn the character's head. So, you turn its head BUT you are obligated to set a keyframe before frame 100 to serve as the start of the turn. Instead of going back in the timeline, wouldn't it be great if you could hit a button on a gui that would automatically set the keyframe for you.
I'm more concerned with the commands for going back in time and setting the keys.

Thanks a bunch!

just use autokey and in the prefs tell it to key all attributes instead of modified attributes.

remember u can simply mmb drag in the timeline while keeping a current frame, then simple press s or wiht suto key on with the right settings, just nudge the model; move rotate etc just slightly.
but mmb dragging the timeline is really faster and use auto key.
very simple imo.
no need for a mel here.

using your example of turning a heaed:

at frame 1 the head is at 0 but a 100 u want to turn the head to the right,
set your initial keyframe at frame 1 for ry to be 0, then just mmb drag to frame 99 and press s [or if u have autokey on, just nudge the head very slightly] then @ frame 100 just key the head turning. fast:beer:

Velusion 06-04-2006 04:28 PM

Vlad, I agree with you. I think that I just got caught up in the challege posed by writing a script to do this simple task.


All times are GMT. The time now is 11:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018