Join George Maestri for an in-depth discussion in this video Understanding the Script Editor, part of Up and Running with MEL Scripting in Maya.
- Scripting in Maya is controlled through the script editor window. Now you can find this in one of two places. We can go into Window > General Editors > Script Editor, or if you have the command line turned on in your interface, which is this one here that says "MEL," we can go over here and find a button for the script editor, so however you get into it, once you do this is what it looks like. Now this window has three main portions.
We have some tools up here, down here in this window, we have what's called the "history window." Now this basically records all the history of all the commands that we've done in Maya. Now I've just opened this scene so I don't have a lot of history right now, but you can see that we have basically just commands that as I do things, so for example if I were to select this chair and move it you can see that it's starting to build history on this.
You can see I selected the chair, I moved it and then I undid the move. So this can be very important because what we can do is we can start to record the commands as we do them, in other words, we can start to create macros, and we do that in the lower window. So here we have a tab based interface that allows us to type in scripts. Now this area can have either MEL or Python script tabs so if we right click over that window we can create a new tab, so I can create a MEL tab, see now we have two tabs for MEL scripts, or if I right click over this do new tab, I can also do one for Python.
Now we're not going to be doing Python scripting in this course, so we can delete the tabs as well. I'm going to right click over this, and just go Delete > Current Tab and you can see how you can create and delete tabs for different scripts, so you can have a script in each tab and just switch between them. Now along the top we have some standard tool bars. One is to load a script, in other words, to load a script from the disk. This one is called Source Script which we'll get to in a little bit.
We also can save scripts to the hard disk for reference, or we could save them to the shelf to create our own custom buttons and we'll get to that as well. Now we can also clear out different types of things. So we have these eraser buttons to clear our history, so if I hit this it clears out the history. We can do the same for the input, which is anything in this tabbed interface down here, or we can clear out both of them. Now we can also display just the top window, just history, just the bottom window, which are just our scripts, or the default which is both.
Now we can also do a number of things. We can turn on or off line numbers in our scripting window, which can be very handy for tracking or going through your script. We can also use these buttons here to execute or play back our scripts. Now we also have a window here that is basically a search field and that allows us to search for specific terms. So if we want to find something in one of our scripts we could do it there. So this is the basics of the script editor.
Hopefully you'll understand where everything is, and as we start working through the course we're going to be using this window a lot. So we'll get the hang of it as we move through the course.
- Using the command line and the Script Editor
- Grabbing Script Editor output
- Creating, loading, and saving buttons
- Working with variables and arrays
- Using conditionals
- Performing calculations with the math, trig, and time functions
- Creating and testing a user interface