View Single Post
05-09-2019, 11:21 PM   #2
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