View Full Version : list key frames

06 June 2011, 09:42 PM
mel script question

How can I list all keyframes on current frame, please.

06 June 2011, 10:33 PM
Hey Farrukh,

I could help you out, it would be easier for me to explain if i have a little more info on what exactly your looking for.

Are you looking for what objects have a keyframe on the current frame? Are you looking for there values? Lastly, are you looking for keyframes on the current frame for all objects in the scene or just a certain object?

06 June 2011, 03:14 AM

I should've just asked you directly hehe.

First off, hope things are well!

So, say I have a sphere.
Its got three keys, frame 1 frame 5 frame 10

so if i'm on frame 1 - I would like to select the keyframe channels, tx,ty,tz,rx,ry...etc on the frame 1
if i'm on frame 5 - select keyframes on that frame of the sphere...
without having to effect other keyframes

thanks Sean!

06 June 2011, 09:18 PM

So here is the basic concept of what you are asking to do (will use "sphere1" as an example).
First you need to get a list of the animcurves on the sphere:

string $obj = "sphere1";
string $animCurves[] = `keyframe -query -name -eval $obj`;

Then you need find the current time:

float $ct = `currentTime -query`;

Then you need to find if a keyframe exists on your current time(one way to do this is use the findkeyframe command, it will the find next keyframe based on the input value, so we need to take your current time and subtract by 1 :

float $getFrame = `findKeyframe -time($ct-1) -which "next"`;

if the current time and the keyframe match we now select the keys on that frame(in this example i am just selected all the keyed channels:

if ($ct == $getFrame) {
select -r $obj;

for ($i in $animCurves)
selectKey -add -k -t $ct $i;
else {warning ("no keys on frame " + $ct);}

hope this helps, if you need me to explain further as always feel free to email me.

CGTalk Moderation
06 June 2011, 09:18 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.