Python syntax for time range in Keyframe cmd?

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
  06 June 2012
Python syntax for time range in Keyframe cmd?

When specifying 'time' in the Python version of the keyframe command, the values are separated by a comma. In Mel they are separated by a colon.
In the manual, they instruct that a range of frames can also be specified, ie:
-time "10:" means all keys from time 10 (in the current time unit) onwards.
-time ":10" means all keys up to (and including) time 10 (in the current time unit).

Python doesn't like that last version (up to and including) because it would start with (,


cmds.keyframe(time=(),r=1,timeChange=12) # All
cmds.keyframe(time=(,5),r=1,timeChange=12) # Error: invalid syntax #

Anyone know the fix?
Thanks.

Edit:
cmds.keyframe(time=(5,),r=1,timeChange=12) # This also fails, it only moves the keys at F5.
__________________
If animation couldn't change the world, it wouldn't be such a Micky-Mouse place.

Last edited by EightBit : 06 June 2012 at 03:30 AM.
 
  02 February 2013
I realize that this is a little old, but I just ran across this problem and wanted to post the answer for others to reference.

The -time flag is allowed to be used multiple times in a single command. In MEL this would be: keyframe -time 1 -time 5 -time 10. Since Python allows an argument to be used only once any flag that can be used multiple times must be passed a tuple, so the previous example would be time=(1, 5, 10). In Python a tuple of a single element is created like this: ( <first entry> , ). So to pass the equivalent of -time "10:" in Python you would do this: ("10:" , ).

e.g. cmds.keyframe(time=("5:",), relative=True, timeChange=12)
 
  02 February 2013
Hey thanks!
__________________
If animation couldn't change the world, it wouldn't be such a Micky-Mouse place.
 
  02 February 2013
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 11:46 PM.


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