Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
Show only
|
Search instead for
Did you mean:
This page has been translated for your convenience with an automatic translation service. This is not an official translation and may contain errors and inaccurate translations. Autodesk does not warrant, either expressly or implied, the accuracy, reliability or completeness of the information translated by the machine translation service and will not be liable for damages or losses caused by the trust placed in the translation service.Translate
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?
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.
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.
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.)
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.
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).
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.
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: