SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.


SM Forums / Maya Questions / Programming / Keyframe mel

Programming MEL Scripts, Expressions & Programming Related Topics

Join the conversation. Reply to post
 
Thread Tools
05-04-2006, 04:56 PM   #1
Velusion
Registered User
 
Velusion's Avatar
 
Join Date: May 2004
Location: Utah, USA
Posts: 369
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!
  Reply with quote
05-04-2006, 05:56 PM   #2
skywola
Registered User
 
skywola's Avatar
 
Join Date: Jan 2004
Location: Tempe, Arizona, USA
Posts: 224
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. . .
__________________
"The Sage as an Astronomer: If you still see the stars as something above you, you lack the eye of knowledge." Friedrich Nietzsche
  Reply with quote
05-04-2006, 08:59 PM   #3
Velusion
Registered User
 
Velusion's Avatar
 
Join Date: May 2004
Location: Utah, USA
Posts: 369
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
  Reply with quote
06-04-2006, 07:40 AM   #4
skywola
Registered User
 
skywola's Avatar
 
Join Date: Jan 2004
Location: Tempe, Arizona, USA
Posts: 224
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.
__________________
"The Sage as an Astronomer: If you still see the stars as something above you, you lack the eye of knowledge." Friedrich Nietzsche
  Reply with quote
06-04-2006, 12:39 PM   #5
Velusion
Registered User
 
Velusion's Avatar
 
Join Date: May 2004
Location: Utah, USA
Posts: 369
That's a very good idea.
  Reply with quote
06-04-2006, 01:02 PM   #6
skywola
Registered User
 
skywola's Avatar
 
Join Date: Jan 2004
Location: Tempe, Arizona, USA
Posts: 224
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.
__________________
"The Sage as an Astronomer: If you still see the stars as something above you, you lack the eye of knowledge." Friedrich Nietzsche
  Reply with quote
06-04-2006, 02:32 PM   #7
vladimirjp
Subscriber
 
vladimirjp's Avatar
 
Join Date: Jun 2003
Location: stuck in the 90's boston, USA
Posts: 1,871
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
__________________
Image dump

Last edited by vladimirjp; 06-04-2006 at 02:34 PM.
  Reply with quote
06-04-2006, 04:28 PM   #8
Velusion
Registered User
 
Velusion's Avatar
 
Join Date: May 2004
Location: Utah, USA
Posts: 369
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.

Last edited by Velusion; 06-04-2006 at 05:15 PM.
  Reply with quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
city mel script omegaend Programming 3 11-04-2011 07:41 AM
Various Mel Scripts equinox Programming 7 14-01-2004 10:07 AM
Uses of MEL nspiratn Programming 5 18-09-2003 02:18 PM
Using MEL to create objects DukerX Programming 17 23-05-2003 06:00 PM
Instructions on Installing MEL Scripts and Plugins tariqrf Maya Basics & Newbie Lounge 4 23-11-2002 07:17 PM