As Maya artists we are constantly encountering new problems and limitations to our work flows. It can be frustrating to attempt a seemingly simple task only to be let down by sub par results or results that just don't work for one reason or another. It can also be tedious to do repetitive tasks manually when a script could do the work for us.
Let me introduce you to a friend of mine named MEL. MEL is short for Maya Embedded Language and it is the backbone of Maya. Everything you do in Maya calls a MEL command. All of our menus, buttons, tools, etc are powered by MEL.
I'm not going to get into the fundamentals or syntax of MEL. I'm not trying to teach you, so much as, inform you as to the importance of learning MEL (at least how to find, install and source/run a MEL script or Maya Command).
OK the B.S. introduction is over, now for the meat and potatoes...
1. Maya MEL Interface
Maya's Script Editor (
Window > General Editors > Script Editor
) is just what it sounds likes, a place to edit scripts. It's also the place where Maya tells us whats going on behind the scenes. Inside of the Script Editor we have two panes. The top pane is history and the bottom is the input. By default Maya shows us a simplified history of whats been happening in our scene. 99% of the time the average Maya user will be more then content with amount of information contained in the standard history pane. On the rare occasion that we need more feedback from our history pane, turn on Echo All Commands (History > Echo All Commands
) in the Script Editor menu. Now be warned that echo all commands uses memory... I don't know how much or if it can be an issues but Its good form to turn it off when not using it.The Input pane is where we can give Maya commands or inputs. At the top of the Input pane you will see two tabs, One named MEL and one named Python. Python is another language that Maya supports but is beyond the scope of this tutorial. For the purpose of this article you just need to be aware of what type of script you are running (
.mel or.py
) and whether you are in a MEL tab or a Python tab when inputting commands. Most of the time you will be in MEL tabs but there is always a chance that the script you're trying to run was written in Python and thus requires a python tab to execute the commands.The most basic example of MEL in action is to type:
sphere;
in the input tab. Note* Every command you execute must end with a semicolon ( ; ). Maya doesn't know what to do with the command if the semicolon isn't present. Hit the Enter Key on the number pad to execute the command. Now you have a nurbs sphere! I know what you're thinking... pointless! Right?Here's the deal, you just learned how to run commands or user made scripts in Maya. Now all you need to do is find the Maya Command or Script you want to use and run it.
2. Installing Scripts
If you're using a user created script, copy the desired files to the scripts folder (located in your
C:\Users\"your name"\(My)Documents\maya\"your Maya version"\scripts
folder) and launch Maya. Once in Maya, open the Script Editor and source (File>Source Script) the script that you want to run. This loads the script into Maya's memory so that it knows what we are talking about when we execute a command. Now just type the proper command to execute the script, just like we did for sphere above. Most of the time the command to execute a script is the same as the name of the script minus the .mel(magicMaker.mel
would be inputted as magicMaker;
). This is not always the case. Some times the author uses different names, so read the help/readme/script comments associated with these scripts to ensure you are on the same page as the creator.On a semi-related note, if you are using someones script, tell them you like it or what could be better... Its the least you can do. People write scripts to make computer work more efficient and bearable for themselves and their studio and they don't have to share. If you use it, show your appreciation for the hard work they did to make your life easier. I find that most people like user feed back... just be constructive if you have a problem/suggestion.
*Script Editor Notes*
- Selecting the text (code / command) before hitting the enter key will keep the text in the input field making it easy edit the previous inputted commands/code.
- You can make a button out of the script by selecting the text in the input field and selecting
File > Save Script To Shelf...
- Maya has a ton of help documentation use it!
- Under Edit menu there are three options at the bottom to clear the History and or the Input panes if things get messy.
- Explore Maya and the Script Editor... I don't have the time to cover every feature, nor do I know what they all do. Investigate!
*Article Notes*
This tutorial / article is not intended to be the be-all end-all MEL reference. This was intended as a beginners guide to understanding what MEL is and how to take advantage of it in its most simple form. If you're a computer scientist and you're upset because I'm not using programmer jargon or missing fundamental scripting concepts in the article, then you're not the person for whom it is intended.
wow this mel maya tutorial is relly good
ReplyDelete