SimplyMaya Forums

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

Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 05-04-2006, 04:56 PM   #1
Velusion
Registered User
 
Velusion's Avatar
 
Join Date: May 2004
Location: Utah, USA
Posts: 368
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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!
__________________
James Rogers
www.morphicmotion.com
Velusion is offline   Reply With Quote
Old 05-04-2006, 05:56 PM   #2
skywola
Registered User
 
skywola's Avatar
 
Join Date: Jan 2004
Location: Tempe, Arizona, USA
Posts: 224
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
skywola is offline   Reply With Quote
Old 05-04-2006, 08:59 PM   #3
Velusion
Registered User
 
Velusion's Avatar
 
Join Date: May 2004
Location: Utah, USA
Posts: 368
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
__________________
James Rogers
www.morphicmotion.com
Velusion is offline   Reply With Quote
Old 06-04-2006, 07:40 AM   #4
skywola
Registered User
 
skywola's Avatar
 
Join Date: Jan 2004
Location: Tempe, Arizona, USA
Posts: 224
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
skywola is offline   Reply With Quote
Old 06-04-2006, 12:39 PM   #5
Velusion
Registered User
 
Velusion's Avatar
 
Join Date: May 2004
Location: Utah, USA
Posts: 368
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That's a very good idea.
__________________
James Rogers
www.morphicmotion.com
Velusion is offline   Reply With Quote
Old 06-04-2006, 01:02 PM   #6
skywola
Registered User
 
skywola's Avatar
 
Join Date: Jan 2004
Location: Tempe, Arizona, USA
Posts: 224
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
skywola is offline   Reply With Quote
Old 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
Thanks: 0
Thanked 4 Times in 3 Posts
Default 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.
vladimirjp is offline   Reply With Quote
Old 06-04-2006, 04:28 PM   #8
Velusion
Registered User
 
Velusion's Avatar
 
Join Date: May 2004
Location: Utah, USA
Posts: 368
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
__________________
James Rogers
www.morphicmotion.com

Last edited by Velusion : 06-04-2006 at 05:15 PM.
Velusion is offline   Reply With Quote
New Thread

« Previous Thread | Next Thread »

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
MEL headache! happymat27 Members Lounge 5 05-12-2010 08:43 AM
MEL headache!! happymat27 Mel Scripts & Programming 1 03-12-2010 03:41 PM

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.