Maya for 3D Printing - Rapid Prototyping
In this course we're going to look at something a little different, creating technically accurate 3D printed parts.
# 1 25-12-2014 , 06:26 PM
Registered User
Join Date: Jun 2014
Posts: 23

How can I have a command that sets the playback min frame to the current frame?

Hi I find myself always struggling to frame the playback min/max.

I would like to make it so that I have the Left key a hot key for setting it such that the playback min frame is set to the current frame, and also that the right key makes it such that the playback max frame is set to the current frame.

# 2 26-12-2014 , 04:55 AM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
A quick look in the animation section of the command reference and the playbackOptions command and it's minTime and maxTime flags was the obvious choice.

In the hotkey editor, assign this command to a key(and create one for the maxTime as well)

Code:
playbackOptions -edit -minTime `currentTime -q`;


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
# 3 27-12-2014 , 04:03 PM
Registered User
Join Date: Jun 2014
Posts: 23
Wow that is awesome!

If I may also ask for one additional code:

I'd also like some hotkeys that will be able to make it such it it will move the min time, max time and currrent frame up by 100.

# 4 28-12-2014 , 02:00 AM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
The building blocks for what you're asking are in the previous code, I'll explain the syntax of this line of MEL code in hopes it'll help you develop your own.
When you call a command, it can be put into 1 of 3 modes using a couple of flags(these flags don't need any values assigned):

-edit or -e for short. This allows you to change the values of additional flags(not all flags can be edited and the help files label them accordingly).
ex:
Code:
playbackOptions -e -maxTime 500;
-query or -q. This returns the value for the flag that follows.
ex:
Code:
playbackOptions -q -maxTime;
create, there is no -create flag to activate this mode, it is the default and is understood when you don't specify -edit or -query.
ex:
Code:
playbackOptions -maxTime 500;
In the case of :
Code:
playbackOptions -edit -maxTime `currentTime -q`;
The `` tells Maya to calculate the contents of the backquotes and return the result and we're using that result as a value for the maxTime flag. Its just quicker to type it this way instead of having to query and store the currentTime in a variable beforehand like:
Code:
int $currentFrame = `currentTime -q`;
or since you said you wanted to add some stuff onto the frames
Code:
int $currentFrame = `currentTime -q` + 100;
then assign the $currentFrame variable to the maxTime flag
Code:
playbackOptions -edit -maxTime $currentFrame;
The good thing about creating the $currentFrame variable is that you are able to reuse it further down the script, if you don't care about having that option then...
Code:
playbackOptions -edit -maxTime (`currentTime -q` + 100);
..would be the same thing.
The parentheses () create an expression out of the contained code. Expressions group parts of the code where operators and values need to be calculated in a particular order to produce a value.

Hope I helped more than confuse user added image. If you have any questions, let me know.


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
# 5 29-12-2014 , 05:11 AM
Registered User
Join Date: Jun 2014
Posts: 23
Hmm Well using that logic I came up with this
Code:
playbackOptions -edit -maxTime (`maxTime -q` + 100);
playbackOptions -edit -minTime (`minTime -q` + 100);
It didn't work....

I'm not very good at this but I was thinking that since the code you first gave me:
Code:
playbackOptions -edit -minTime `currentTime -q`;
Sets the min time to the current frame, and later you said you can add numbers in there, and I knew that I wanted the time to simply all go up by itself by 100, that it might look something like that.

# 6 30-12-2014 , 03:47 AM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
In your line:

Code:
playbackOptions -edit -maxTime (`maxTime -q` + 100);
you are trying to use maxTime as if it was a command, it is not. It's merely a flag, an option associated with the a command, the playbackOptions.

So you need to specify what command you're trying to execute then ask it questions.

Code:
playbackOptions -edit -maxTime (`playbackOptions -q -maxTime` + 100);
Maya has tons of commands. Get ready for a likely bad analogy. Imagine walking up to someone in front of a store room full of boxes and barrels and wondering how many boxes are inside but what you actually asked was "How many are in there?". If you get a reply like "How many what? Where?", it wouldn't be weird since the question was rather vague so yeah Maya will act up since the question didn't make sense. In MEL , the likely query statement for this store room command in this analogy would be:

Code:
storeRoom -q -numberOfBoxes;
Instead of the vague:

Code:
numberOfBoxes -q;
As there could be another command in the language named truckLoad that also has the flag -numberOfBoxes and even a -numberOfBarrels flag too. Hope that helps.


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
# 7 30-12-2014 , 07:56 AM
Registered User
Join Date: Jun 2014
Posts: 23
Hmmm I see, this works for the most part:
Code:
playbackOptions -edit -maxTime (`playbackOptions -q -maxTime` + 100);
playbackOptions -edit -minTime (`playbackOptions -q -minTime` + 100);
But, if I may, can I also ask how I would also make it so that the currenttime jumps up 100 frames?

# 8 31-12-2014 , 02:14 AM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
Since the currentTime command is especially specific it doesn't have many flags and since there is only one timeline the create and edit modes do the same thing.

Code:
currentTime 100;
and

Code:
currentTime -e 100;
Mean the same thing. So like my previous post:

Code:
currentTime (`currentTime -q` + 100);
or

Code:
currentTime -edit (`currentTime -q` + 100);
Same thing.


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
# 9 31-12-2014 , 07:58 PM
Registered User
Join Date: Jun 2014
Posts: 23
Thanks this is awesome!

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads