cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Slow down

Slow down

How about a slow down option in playback control?

19 Comments
medryks
Alumni
Status changed to: Gathering Support

Hey @Anonymous , thanks for your idea! Can you provide a bit more context by what you mean? Do you mean slowing down your animation playback speed in the viewport? If so, you can change your playback speed to half speed (or a custom speed) in the animation preferences. Otherwise, can you elaborate on your request?

 

Screen Shot 2019-02-01 at 1.26.22 PM.png

 

Thanks again!

 

Stefania

Anonymous
Not applicable

Hi @medryks 

Yes a more accessible option directly in the user interface.

And, if you can help me, I can not find any command to create a script for this "tool".


 

Thanks

florian.dyck
Advocate

Have you tried time scale for animations? Very useful, can be manipulated with graph

Anonymous
Not applicable

Hi  @florian.dyck 

Time scale don't need to extend the time range of the animation?

 

No but I made two command line to switch between the two speed
I still don't know how to make a switch button.

 

//Real Time Speed

playbackOptions -ps 1;  

 

//Half Time Speed

playbackOptions -ps 0.5;

kevin.picott
Alumni

If I'm not mistaken what you're asking for are commands to create a user interface that only controls your playback speed. Creating custom interfaces is a large topic. You can get simple examples by looking at the command documentation's "Windows" section http://help.autodesk.com/view/MAYAUL/2019/ENU/?guid=__CommandsPython_index_html or go more in-depth with PyMel's "Building User Interfaces" section http://help.autodesk.com/view/MAYAUL/2019/ENU/?guid=__PyMel_ui_html.

 

Here's one simple approach I created by adapting the sample code from the radioButtonMenuGrp command documentation. It creates a window consisting of a radio button that lets you toggle back and forth between slow and fast playback speeds using the commands you've found:

 

import maya.cmds as cmds

def go_fast(the_button):
    cmds.playbackOptions(ps=1.0)

def go_slow(the_button):
    cmds.playbackOptions(ps=0.5)

# Enable the button representing the current speed
starting_selection = 1
if cmds.playbackOptions(query=True, ps=True) == 1.0:
    starting_selection = 2
    
# Create a new window with a radio button for selecting the playback speed
window = cmds.window(title="Quick Options")
cmds.columnLayout()
cmds.radioButtonGrp( label='Playback Speed'
                   , labelArray2=['Slow', 'Fast']
                   , numberOfRadioButtons=2
                   , select=starting_selection
                   , onCommand1=go_slow
                   , onCommand2=go_fast )
cmds.showWindow( window )

You might also consider using a custom shelf. If you create your own shelf then you can select your command code in the script editor and drag it onto the shelf. It will ask what language you want your shelf button to use (MEL in your case) and create a new button for you that will execute your code when pressed. Do it for each of your two playback speed commands and you'll have buttons on your shelf that toggle your playback speed.

Anonymous
Not applicable

Thank you very much @kevin.picott  for this useful script. I meant a simple button that you press, like a power button which allows switch between two values, in mel code for start because for now I'm not used to programing

 

I can also use a python RUNTIME command wich I put in a marking menu like I use usually.

 

Thank you for taking the time to find a great solution.

kevin.picott
Alumni

Perfectly understandable; Mel was created to be an easier language for non-programmers to pick up. Fortunately most of the Maya commands are available in both languages so it's not difficult to switch. Here's a Mel example that creates a window with a single button that goes back and forth between slow and fast. (Were I building an actual user interface I'd make it prettier and maybe add some colours to make it more obvious what mode it's in.)

 

proc speed_button_pressed(string $the_button)
{
    print( "Button is " + $the_button + "\n");
    float $current_speed = `playbackOptions -q -ps`;
    string $current_label = "";
    if( $current_speed == 1.0 )
    {
        $current_speed = 0.5;
        $current_label = "Go Fast";
    }
    else
    {
        $current_speed = 1.0;
        $current_label = "Go Slow";
    }
    playbackOptions -ps $current_speed;
    button -edit -label $current_label $the_button;
}

string $window = `window -title "Quick Options"`;
columnLayout;
string $speed_button = `button -width 100`;
button -edit -command ("speed_button_pressed(\"" + $speed_button + "\")") $speed_button;
speed_button_pressed( $speed_button );
showWindow $window;
Anonymous
Not applicable

@kevin.picott 

It's super nice. You've already give me a python script, I don't want you to make loose your time. May you tell me where can I find great course on Lynda or Pluralsight website please?
Again thank you.

kevin.picott
Alumni

You can try "Enhancing Your Maya Toolset with Mel" or "Python for Maya Fundamentals" on Pluralsight, depending on how comfortable you are with programming. If you are going to be doing a lot of interface creation I'd highly recommend learning Python as it can help you get a lot more done. There's also "Learning Mel Scripting" on Lynda.com (now LinkedIn Learning).

Anonymous
Not applicable

Well,I think I'm going to opt for the two options to see where I'm the most ease
Thanks a lot

BenediZ
Collaborator

Just a tip

You can also just make a shelf button and put one speed command on single-click and the other speed on double-click.

So you have just one button with both options.

I use this double-click option for many small tasks…

Anonymous
Not applicable

Thanks

Anonymous
Not applicable

Hi @kevin.picott ,

I've followed the course you had advised to me for learning MEL on LinkedIn and Pluralsight.

Have you an idea of how to dive deeper learning Mel scripting, I know obviously that I've to practice more and more.

And I've also a question about a command line that I made and give me a headache. It's a command I need to put in a marking menu which allows me to switch between two states and that gave me an error. 

If you will have time could you says me where I'm wrong please.

 

string $displayAffected = `displayPref -da`;
menuItem -e -checkBox -e ( !`displayPref -e -checkBox -da $displayAffected` ) $displayAffected; 
kevin.picott
Alumni

Practice is the best way - and also looking at example code that is within Maya, there is plenty of it.

 

When you post that you have an error it's a good idea to post the error message, otherwise we have to guess. In this case I'm pretty sure the error you're getting is in the first line since you haven't told the command you are querying:

string $displayAffected = `displayPref -q -da`;
Anonymous
Not applicable
string $displayAffected = `displayPref -q -da`;

menuItem -e -checkBox -e ( !`displayPref -q -da true $displayAffected` ) $displayAffected; // Error: line 2: Invalid object or value: 1 //

I've tried to set the value to TRUE

I've also tried to make a FOR loop in another same script to do the same action but still not working.

kevin.picott
Alumni

You should also look into the online documentation (e.g. https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2019/ENU/Maya-Tech-Docs/Comman... Your command syntax has many problems with it:

  • You should only have one "-e" flag (the first one)
  • $displayAffected is an int, not a string
  • $displayAffected should not be a parameter to "menuItem", it should be the name of the menuItem control
  • The inner displayPref command doesn't take a "true" parameter to the queried flag, that's only for Python
  • Similarly it doesn't take the $displayAffected parameter - that's what is being queried

You should have something like this:

int $displayAffected = `displayPref -q -da`;
menuItem -e -checkBox (!$displayAffected) $menuItemName;
Anonymous
Not applicable

Thanks you so much @kevin.picott  , I will practice more to understand the mel syntax.

Anonymous
Not applicable

 Thank you so much @kevin.picott  I've got it

 

 

int $displayAffected = `displayPref -q -da`;

SelectTool -e -cb (`displayPref -da (!$displayAffected)`);

 

tj.galda
Alumni
Status changed to: Implemented
 

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea