Scripting (Maya)

From TOI-Pedia

Introduction to scripting

MEL Script: Iceray (M. Wieringa)

Maya is a very broad software application with numerous possibilities and applications. Nevertheless is it's flexibility one of the key features: there are several options to change the program to your own needs and demands and to add new functionality yourself. One of the key components to do that is the embedded support voor scripting in Maya. Maya currently supports two scripting languages: MEL (Maya Embedded Language) and since Maya 8.5 Python.

This extensive scripting support is what makes Maya an interesting application for (but not only) researchers. Ground-breaking, new designs often demand new tools. They can be created using scripts in Maya. It allows the designer to create outside-the-box designs.

Finally a general remark towards scripting: at first it may seem difficult to write a script that is useful and powerful. The most important thing is to start on a small scale and improve and expand your script step by step. Mastering scripting is foremost done just by practice. Start off with what you know or understand and go from there. Split the assignment and test en try each part. That way you'll get to results faster than you might have expected. Problems may seem daunting beforehand, but may be solved more quickly than you had anticipated. Moreover it allows you to trace any mistake if your script doesn't do exactly what you had in mind.


MEL Scripting in Maya is more fundamental to Maya than you might have thought: the entire interface of Maya as you know it is written in MEL. Everything you do and see in the interface corresponds with one or more MEL commands.

MEL Scripting in Maya


Support for Python was added because Python is a very popular general scripting language and because it adds the possibility to use Object-Oriented Programming (OOP).

Information on Python scripting is planned, but not yet available at this moment.

The script editor and external editor

You can enter commands in Maya in the Script editor. You can open the Script Editor through Window > General Editors > Script Editor. This interface is used to enter commands and scripts, but the history panel also provides feedback.

Maya scripteditor.jpg

If the Script Editor is opened, you'll see a window similar to the image above. The windows is divided into two parts: The top part is the history, the bottom part is where you can type. The history probably already contains some output. You'll notice that most actions in Maya result in output in the history panel. It shows the commands that are being executed and the results of those commands.

If make a polygon cube for example, we'll see something like this:

polyCube -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -tx 1 -ch 1;
// Result: pCube1 polyCube1 //

The first line is the command being executed. It shows the name of the command and several options, called flags for that command. You can recognize a flag by the dash (-) prefix, followed by one or more values.

The second line is the result of the commands. In this case it shows the name of the cube that has been created.

However, the functionality of the built-in Script Editor in Maya is limited. As soon as your scripts gets a little more complex, it's recommended to use a different editor. (The script editor in Maya 8.5 is improved dramatically, but still an external editor can be nice). One of the possibilities is Crimson Editor. If you save your file with the .mel extension, Crimson will understand it's a MEL-script and will 'color code' your script to improve readability, for instance: commands and variables get their own color. The extension .mel isn't in the standard list of file types when you save a file in Crimson. You need to suffix (type) .mel yourself.

You can use Copy-Paste to get your script from Crimson to the Script Editor van Maya to execute it, or you can save it in Crimson first (always a good idea) and the use File > Open Script in the Script Editor.

Overview of Maya topics

Maya main index

Personal tools