Maya Training

Introduction to Hard Surface Modeling

Maya Training

Interiors and Furniture Vol 1 & 2 - Modeling & Cloth

Maya Training

Shading, Lighting and Rendering the Bedroom in MR

Maya Training

Robot volume one - Modeling with animation in mind

Maya Training

Spach-Alspaugh House the complete courseware

Maya Training

Burt The Cartoon Dinosaur Vol 01 - Modeling

New Maya Training

Robot Volume 02 - Hybrid Rigging
You are here > Home > SimplyMaya Community Forums
Loading

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 05-04-2006, 05: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, 06: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, 09: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, 08: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, 01: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, 02: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, 03: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

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 03:34 PM.
vladimirjp is offline   Reply With Quote
Old 06-04-2006, 05: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 06:15 PM.
Velusion is offline   Reply With Quote
Reply


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

Thread Tools





A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2015 SimplyMaya - vBulletin® Copyright © 2000-2015, Jelsoft Enterprises Ltd.