Changing timeslider in Graph Editor

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  01 January 2011
Changing timeslider in Graph Editor

Hey all,

Im trying to write a little script that means that when I select a key in the graph editor the time automatically updates to that frame so I can see my adjustments in the persp. At the moment when animating each time I adjust a key in the graph editor I have to also move the timeslider onto that frame so I can actually see my changes. I have -

import maya.cmds as cmds frame = cmds.keyframe( q=True, sl=True, tc=True);
cmds.currentTime( frame[1] );

I need this to do it everytime I select a key. At the moment I have to run it everytime which completely take the point out of it. How do I get this to run in the background constantly?

Does that make sense? Probably a noob question I know.

  01 January 2011
if you wanted to auto-run something everytime you made a selection change you need to wrap it up in a scriptJob. You'll also need to put a little more error checking in your code too, as afaik there's no separate scriptJob event to distinguish between normal node selection and keyframe selection.
scriptJob -event "SelectionChanged" "runThisFunc";

Last edited by NaughtyNathan : 01 January 2011 at 02:41 PM.
  01 January 2011
Cheers for the point in the direction Nathan. scriptJob was just what I was looking for

Managed to get the script working quite nicely in the end with it selecting the middle frame if you select various at once.

global proc jumpToFrame() {
   	float $frames[] = `keyframe -animation "keys" -q -sl`;
   	if ( $frames[0] > 0 ) {
   		$size = 0;
   		$sum = 0;
   		for( $i in $frames )
   			$sum += $i;
   			$size += 1;
   		$average = $sum / $size;
   		currentTime $average;
   scriptJob -event "SelectionChanged" "jumpToFrame";

Thanks again! Sim
  01 January 2011
I usually hold "k" and click at whatever key I'm currently editing.
The Pirate
Duplicator Series
  01 January 2011
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 11:37 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.