How to get the currently selected keyframe?

How to get the currently selected keyframe?

rafGCQG8
Contributor Contributor
594 Views
1 Reply
Message 1 of 2

How to get the currently selected keyframe?

rafGCQG8
Contributor
Contributor

Hi there,

 

I'm writing a Maya plugin in python and it has become necessary for me to be able to get the current user selected keyframe. This function will go to keyframe 0, copy all information related to all bones and then paste it on the current keyframe the user had selected before pressing the button. 

 

E.g. in MEL:

currentTime 0 ;
select -r Root hip abdomenLower ...etc ;
timeSliderCopyKey;
currentTime 2;
timeSliderPasteKey false;

but currentTime 2; would be equal to the keyframe the user is on.

Any help would be greatly appreciated, thank you:)

0 Likes
Accepted solutions (1)
595 Views
1 Reply
Reply (1)
Message 2 of 2

rafGCQG8
Contributor
Contributor
Accepted solution
currentTime(query=True);

This returns the current keyframe. The solution in python was:

import maya.cmds as cmds

currentKeyframe = cmds.currentTime(query=True)
...
cmds.currentTime(currentKeyframe)
0 Likes