Creating a custom MEL script in Maya can save a lot of time. Especially when we are running the same commands over and over again.
In this article, we will demonstrate a very simple concept of using three common commands and how we can benefit by creating a custom MEL script that will be used to execute all three of them at once. After that, we will put that custom MEL script on a shelf, for easy access and later use.
The most common commands that I use in the modeling process in Maya:
- Delete history
- Center pivot
- Freeze transformations
All three of the above commands are already separately on the modeling shelf in Maya. But you will find yourself using them all the time when working on your 3D model.
Wouldn’t it be better to just click on a single command (on a shelf) and execute all three commands at once? It is for sure, at least for me.
As I have already said, our example is pretty simple. You can extrapolate the principle from this and apply it to more complex stuff.
Let’s create a simple MEL script for all three commands mentioned above, by using the Script Editor in Maya.
Feel free to watch the video below, to see the demonstration in action. However keep reading this article, for more in-depth information about the creation of the custom MEL script.
Relative posts about MEL scripting in Maya:
- Combine curves in Maya as one piece through a simple line of MEL script
- Select Random Faces in Maya with Mel Script
- Create facial GUI controls with free mel script in Maya
Create a Custom MEL script in Maya:
Open up the Script Editor in Maya, by going to Windows – General Editors – Script Editor.
1 Step (write the script):
Type the following lines in the Script Editor:
DeleteHistory;
CenterPivot;
FreezeTransformations;
Now we have written our MEL script, let’s put it on a shelf for easy access.
2 Step (put the script on a shelf):
Select and highlight all the lines of the code above and with the middle mouse drag and drop it to a specific shelf in Maya.
I put mine on the Modeling shelf next to the same separate commands
3 Step (customize) optional:
After putting a new MEL script on a shelf, you may want to make it more recognizable, like give it a name, icon, etc.
To do so, hover over your new MEL script right-click and choose open or edit.
A new popup window appears (Shelf Editor):
More in-depth info about the Shelf Editor here.
Conclusion:
Creating a custom MEL script in Maya is an easy and efficient way to automate repetitive tasks. We can save a lot of time and effort by combining frequent commands. In that way, we can focus more on the creative process of our project. Also, make sure to put your new custom script on a shelf in Maya, for easy access.
We can create custom MEL scripts not only for our modeling process but in rigging, animation, etc. If a task is frequently used you can create a script for it.