View Full Version : move keyframe


modi
10 October 2007, 06:44 PM
Hi there, i want to assign a hotkey where i can select a keyframe in the timeline and when the hotkey is pressed, say Ctlr + then it moves only that keyframe forward by 1 frame, and when i hit Ctrl - it moves only that keyframe i'm on back one frame.
It would be even cooler if i could be anywhere in the timeline, not necessrily on a key frame, and when i pressed the hot key it found the next keyframe and moved it backward or forward accordingly.
Any one know what the mel is?
cheers
-Modi

modi
10 October 2007, 08:25 PM
ok, i figured out how to move the keys forward or backward in the timeline without selecting the keys in the graph editor
keyframe -t `currentTime -q` -edit -r -timeChange 1;
But this only works if i'm on a key in the timeline, i'd like to know how to use this command if it does not find a key on the current time,query the next key on the timeline and move it.
thanks
Modi.

Segmoria
10 October 2007, 01:32 PM
Use this instead:
keyframe -t `findKeyframe -timeSlider -which next` -edit -r -timeChange 1;

modi
10 October 2007, 06:58 PM
Excellent, now if only i could combine the 2.
If there is a key on the current time, edit that keyframe, if NOT exist then Find next keyframe.
I'm a total noob at mel and would appreciate it if someone could tell me how i could code this if statement.
thanks
Modi.

modi
10 October 2007, 07:57 PM
ok, i'm trying to learn , here is what i have so far

$cTime = `currentTime -q`;
$keyFound = `keyframe -t $cTime -q -tc`;
if ($keyFound == 0)
keyframe -t `findKeyframe -timeSlider -which next` -edit -r -timeChange 1;

else if ($keyFound == 1)
keyframe -t `currentTime -q` -edit -r -timeChange 1;

The problem with this is $KeyFound is not returning a 0 or 1, it returns the current time instead or nothing if it does not find a keyframe.
Any tips?

Segmoria
10 October 2007, 09:49 PM
Try this:

int $currentTime = `currentTime -q`;
if (size(`keyframe -time $currentTime -query`) !=0)
{
keyframe -t `currentTime -q` -edit -r -timeChange 1;
}
else
keyframe -t `findKeyframe -timeSlider -which next` -edit -r -timeChange 1;

modi
10 October 2007, 10:21 PM
:thumbsup: thank you.

CGTalk Moderation
10 October 2007, 10:21 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.


1