In Lesson 1 of the entire chapter, I was introduced to the basics of MEL scripting, eg. MEL command lines and script editors. By using MEL scripting, I was able to create polygons onto the stage without needing to use the interface provided by Maya. With the help of the script editor, I was able to enter in codes and creating polygons with different heights and positioning them into different x,y,z axis of the stage. Even renaming the polygons' name could be done through the script.
![]() |
| Adding different polygons onto the stage by using script editors. |
I found out that the Script Editor is a really useful tool especially when I want to have a look at the entire history of tools and changes that I've made in my animation. All the values and positions could be seen as long as I know how to read the MEL scripts.
Not just positioning the polygons, the polygons could be moved by using codes in MEL scripting such as, "move -r -5 0 0;". As well as removing objects from the stage by the command, "delete;". This would sum up Lesson 1.
Lesson 2
In lesson 2, I'm tasked to screenshot a lit and rendered cube with the properties of, Width = 2, Height = 2, Depth = 3. First, creating a polycube by using codes. "polyCube;" is the code to creating a cube in the stage. Then editing the different properties by the following three commands, "polyCube -edit - height 2;", "polyCube -edit -width 2;", and "polyCube -edit -depth 2;"
Next, I'm tasked to insert a directional light using codes, and through that, renaming it to main_light, setting attributes for it as well. All these could be achieved simply by scripting, hence, with the knowledge of scripting, an animator could execute fast commands through the script editor.
![]() |
| Adding in directional lights and setting its resolution through scripting |
Re-positioning of the directional lights and controlling its intensity with the following codes
![]() |
| This is the rendered image for Lesson 2. By the use of directional lights and shadows using the MEL scripting language, such images could be modeled and made in Maya. |
In the Lesson 3, I will be handling with a barrel, learning how to make use of the script to show a rolling barrel animation. Through Autodesk Maya tutorials, I will learning how to use codes to rotate anything that could be found the stage, learning that MEL Script Editor could recognize most programming languages.
First, rotating the barrel with the following codes, "rotate -r 0 0 90;". This allows the barrel to be rotated in 90 degrees of its z-axis. Further into the tutorials, I found out that MEL also supports other data types that are common to most other programming languages. A testing can be made to show this.
![]() |
| Rotating the barrel to 90 degrees in the z axis |
![]() |
| The Script Editor could recognize most of the programming languages |
In the above image, the output of the Script Editor shows, "this is a test" at the bottom right of the screen. Also, variables can be declared and assigned a value in the same statement.
To declare an int variable, type in the following codes of, "int $testInt = 5; print ($testInt/2);". The output should display the number of, "2", as seen in the image below.
![]() |
| Declaring an integer variable in the Script Editor and an output of ,"2" can be seen in the output portion. |
With the knowledge of this, we are ready to start with animating the rolling barrel. With the codes given,"duplicate; move -r 0 0 $diameter_barrel;", the barrels will be duplicated and aligned side by side with each other. The variable of $diameter_barrel is declared previously in the starting of the tutorial, allowing the scripting to recognize it and re-position the barrels side by side to each diameter of the barrel being duplicated. This can be seen in the image shown below:
![]() |
| Duplicating the barrels in the first row with the used of the declared variable previously made in the starting part of the tutorial, known as $diameter_barrel. |
With that, the first row of barrel is completed. To stack the barrels in a triangular arrangement by duplicating the existing row in both X and Y, a little part of trigonometry is needed. The following is the reference provided by Autodesk Maya from the website: http://download.autodesk.com/us/maya/Maya2012_Getting_Started/index.html.
![]() |
| Explanation of triangles given by Autodesk Maya through basic trigonometry. |
![]() |
| This diagram aids in the stacking and positioning of the barrels using basic mathematical functions and degree to radian conversions that could be executed in MEL scripting. |
With reference to the above images, we could declare a new variable to store the value of the Y offset by typing the following: "float $Y_offset;". Also, by using some mathematical functions, with the following sentence: "$Y_offset = $diameter_barrel * (sin(deg_to_rad(60)));" Extracted from the website:"The assignment operator evaluates the right and side of the expression and assigns it to the left hand side. The degree to radian conversion function is the first to be evaluated, as it is within the most interior set of brackets. The sine function calculates the sine of the angle given in radians. The sine value is multiplied by the diameter to calculate the Y offset. The variable is assigned the calculated value." A notice that has been given from Autodesk Maya would help deeper understand with the following functions, "The variable $diameter_barrel does not change in value. Only the variable on the left side of an assignment operator changes in value."
![]() |
| Conversion done through MEL scripting from degree to radians. The result is being highlighted in the image above. |
To Stack the rows of barrels
When stacking the barrels, the using of the $Y_offset would really help a lot since the values were already placed into the variable, done in the previous step.
![]() |
| With the help of the variable $Y_offset, the barrels could be positioned easily. |
To Add Rigid Body Nodes to the Barrels using MEL
In this step, we will be adding "weight" to the barrels through the use of MEL. Furthermore, the gravity of the stage could be declared with the dynamics of the animation being created.
![]() |
| With the following codes, dynamics of gravity will be added into the animation. |
To Create a Plane for the Barrels to stimulate against
To allow the barrels to be stimulated, we have to create a plane to allow them to stimulate against. Then selecting the plane to add rigid body nodes to it as well.
![]() |
| Adding a plane and rigid body nodes to it to allow the barrels to stimulate against it. |
As result for the whole of Lesson 3, the following could be stimulated and seen in the playblast shown in the video below:
In the video shown above, we could see that the barrels falling against each other and took awhile before slowing down until a complete stop, something that's really interesting done through MEL Scripting.
Through Lesson 3, I've learnt the importance of MEL Scripting even more, knowing that it could help adding dynamics such as gravity, as well as declaring variables and the calculation of mathematical functions to be used in animations. They are really important and I've learnt so much in just through the whole of Lesson 3.
For Lesson 4, I'll learning the basic codes to create windows and user interfaces in Maya through a built-in Maya procedure. In the first exercise, I'm given the codes to enter into the Script Editor, creating a window, showing it too at the same time. The example can be seen below.
Next, with the following codes of, "window -resizeToFitChildren 1 testWindow; columnLayout;" , a window with the title, "testwindow", can be created and shown after entering them.
Further into the exercise, I'm taught with the codes of creating windows but not showing it out in the user interface. And also creating windows to delete away the previous window. In reference with the image below, 2 concepts are taught by Maya (extracted from http://download.autodesk.com/us/maya/Maya2012_Getting_Started/index.html):
1) The if statement allows a certain part of code to execute depending on a condition. The section of code within the curly braces only executes if the statement inside the parentheses evaluates to true.
2) The paired back-ticks within the parentheses (' ') indicate that the commands within them are evaluated first. This is a useful part of writing MEL code: you can make certain commands (here, the conditional statement) dependent on other commands (here, the evaluation of whether the window exists), which execute and evaluate first.
Together, the if statement and the evaluation mean that only if the result of the window existence query is "1" (the window exists) is the window deleted. Otherwise, the section of code within the curly braces is skipped.
These concepts are really important and as of creating windows, I have to continuously keep track of the windows that are created and which ones should be deleted as Maya will not inform if the window does no exists or such, due to Maya skipping that section of code that does not "exist".
Buttons to store variables can be created too through MEL Scripting. The following shows the codes and how they are able to create a window with buttons.
Procedures are a set of instructions that allows the user to separate a section of the script and reuse whenever needed. The following example shows how the makeroll procedure can be made with the help of a polyCube. A makeroll procedure can be made by typing in the following: "makeRoll roll_Cube 0 1 1 0;"
Time to time we'll see files called Maya Script files. Problem is, we have to learn how to actually load them into Maya. To do this, go to File > Load Script in the Script Editor. When loaded, you should be able to see the script in the Script Editor in the MEL bottom column. The use of this helps to load User Interface windows saved in a script. You can see the example below:
These created buttons does not do anything even when clicked or slid. In the following examples, would show how the user interface would be linked to the buttons so that they can be used, and also saving the interface for future use.
After going through Lesson 4, I felt that Autodesk Maya is a very flexible program that allows the animator to create user interface windows and change every detail and parts of Maya just by the use of MEL Scripting. With the help of MEL Scripting, I find Autodesk Maya being a very customizable, allowing it to change to the liking of how the animator wants it to be. Learning this really do help and gives me deeper understanding of Autodesk Maya.
For Lesson 4, I'll learning the basic codes to create windows and user interfaces in Maya through a built-in Maya procedure. In the first exercise, I'm given the codes to enter into the Script Editor, creating a window, showing it too at the same time. The example can be seen below.
![]() |
| Creating a window in Maya |
![]() |
| Creating a window with the title: "testwindow". |
Further into the exercise, I'm taught with the codes of creating windows but not showing it out in the user interface. And also creating windows to delete away the previous window. In reference with the image below, 2 concepts are taught by Maya (extracted from http://download.autodesk.com/us/maya/Maya2012_Getting_Started/index.html):
1) The if statement allows a certain part of code to execute depending on a condition. The section of code within the curly braces only executes if the statement inside the parentheses evaluates to true.
2) The paired back-ticks within the parentheses (' ') indicate that the commands within them are evaluated first. This is a useful part of writing MEL code: you can make certain commands (here, the conditional statement) dependent on other commands (here, the evaluation of whether the window exists), which execute and evaluate first.
![]() |
| "if" statement used in MEL to delete away existing windows. Explanation of the codes can be seen above and below the image. |
These concepts are really important and as of creating windows, I have to continuously keep track of the windows that are created and which ones should be deleted as Maya will not inform if the window does no exists or such, due to Maya skipping that section of code that does not "exist".
Buttons to store variables can be created too through MEL Scripting. The following shows the codes and how they are able to create a window with buttons.
![]() |
| Creating windows with buttons to store variables |
Procedures are a set of instructions that allows the user to separate a section of the script and reuse whenever needed. The following example shows how the makeroll procedure can be made with the help of a polyCube. A makeroll procedure can be made by typing in the following: "makeRoll roll_Cube 0 1 1 0;"
![]() |
| makeRoll procedure being executed to the polyCube, making the cube roll when being moved and when the frame is set more than 2 |
Time to time we'll see files called Maya Script files. Problem is, we have to learn how to actually load them into Maya. To do this, go to File > Load Script in the Script Editor. When loaded, you should be able to see the script in the Script Editor in the MEL bottom column. The use of this helps to load User Interface windows saved in a script. You can see the example below:
![]() |
| Script loaded into the Script Editor |
![]() |
| When the script is loaded, this window will appear, which has been created by the script. |
These created buttons does not do anything even when clicked or slid. In the following examples, would show how the user interface would be linked to the buttons so that they can be used, and also saving the interface for future use.
![]() |
| This is the user interface created after going through Lesson 4, really tedious process and requires lots of understanding. |
![]() |
| This line of code will help to save the user interface for future use. |
After going through Lesson 4, I felt that Autodesk Maya is a very flexible program that allows the animator to create user interface windows and change every detail and parts of Maya just by the use of MEL Scripting. With the help of MEL Scripting, I find Autodesk Maya being a very customizable, allowing it to change to the liking of how the animator wants it to be. Learning this really do help and gives me deeper understanding of Autodesk Maya.
















































