SimplyMaya Forums

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


SM Forums / Maya Questions / Programming / Current Time goes to selected Key frame?

Programming MEL Scripts, Expressions & Programming Related Topics

Join the conversation. Reply to post
 
Thread Tools
08-04-2019, 07:43 PM   #1
Louaye
Registered User
 
Join Date: Mar 2007
Posts: 1
Current Time goes to selected Key frame?
Hello Script Wizards!

I'm looking for a script that will change the current time to whatever key frame I have selected.

For example, in the graph editor, I'm on frame 30. I select a key on a curve on frame 50, run the script, and it will change the current time from 30 to 50.

I'm trying to write the script myself but I don't know how to query the time from a selected key frame. My scripting skills are weak! Any help will be appreciated.

THANK YOU!
  Reply with quote
05-09-2019, 11:21 PM   #2
Intuition
Registered User
 
Join Date: Sep 2019
Posts: 2
You can do this pretty easy.

you can use the keyframe mel command to do a query.

keyframe -query -lastSelected -timeChange;

Whatever keyframe you last select in the graph editor the mel command above will report the frame number as the result.

Then there is a basic mel command which sets the current time.

currentTime 105;

The "105" entered above is just an example that will set the current frame to frame 105. But you can make it any frame you want.

So in order to script this you'll want to save the result of the first query into a variable.
Perhaps a float variable since you are saving a numeric value.
Use a variable name that matches what you are doing so you know what the variable is for.
Like $grabTime.
Tnen use that variable as the input for currentTime.

So like this. Copy paste the lines below this one.

// select keyframe in graph editor then run this.
float $grabTime[]=`keyframe -query -lastSelected -timeChange`;
//set currentTime to result saved in variable.
currentTime $grabTime[0];
  Reply with quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Crash when painting weights Krazypoe Maya Technical Issues 0 07-12-2014 11:58 PM
Key Framing Issues coldsnap Maya Basics & Newbie Lounge 1 09-10-2013 07:39 PM
procedure within procedure.??? ieoie Programming 12 07-10-2013 09:20 PM
Theoretical Physics and the Quantum Mind G-Man Maya Basics & Newbie Lounge 80 30-05-2010 09:16 PM
Batch rendering seems to repeat itself alienscience Maya Basics & Newbie Lounge 7 01-02-2005 08:19 PM