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 CLOSED
 
Thread Tools Search this Thread Display Modes
Old 01 January 2011   #1
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.



Cheers
Sim
 
Old 01 January 2011   #2
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";
:nathaN

Last edited by NaughtyNathan : 01 January 2011 at 02:41 PM.
 
Old 01 January 2011   #3
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
 
Old 01 January 2011   #4
I usually hold "k" and click at whatever key I'm currently editing.
__________________
The Pirate
Duplicator Series
 
Old 01 January 2011   #5
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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 04:51 PM.


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