Learning MEL – Step #2 – The First “Hello World” in MEL

Now It is the time of a practical first project. In this project we print a “Hello World” in Maya. So it is very significant to ask questions regarding the project.

Project-Related Questions

  • What is/are the function of the script?
  • What is/are the design, order and/or segment of execution?
  • Command and Functions

It is very important to ask these questions from yourself, and in most of our tutorials we indeed ask these questions. Now, I answer them one by one.

Answers to Project-Related Questions

        What is the function of the script?

The function of the script is that: it prints a text. You type your text, and when executing, it prints in Maya Command Line.

         What is the design, order and/or segment of execution?

In this project we are not going to design an UI (window), we want only a script. This means that our planning focuses only on the script itself. The script gathers the text and then gives it to the “print” function for the further execution.

          Commands and Functions

We need two important parts:

  • An area to store/put text
  • An area to print the “text”

Now it is the moment of writing the script.

A “function” is something in the script that would do a job. It executes something. Functions may or may not accept parameters. Many of the have parameters, but they are optional to be used or not. In this project we are not going to use any parameters.

Another necessary part is the text. “Print” function is a function that requires a text. You must give it a text for printing it. This is our script:

print “Hello World!”;

Thanks, we are done! Now run the script, for running it you need to hit the enter-button or the play icon on the script editor. Get used to select the entire script and then execute it. It will save your text in the script.

Now let’s begin to dissect the script:

We have three parts: print + “Hello World” + ;

Yes the semi-column is very significant, otherwise you will receive a syntax-error. It tells Maya that OK this line is complete and you can interpret it as a single statement.

Note!Programming language’s line is different from ordinary language’s. Statement is calculated from previous semi-column to the next semi-column. The above statement could have written like this:


“Hello World”


Because spaces and line breaks are not calculated in interpretation, and in some rare cases they are, but assume them not to be.

First word is “print”. If you use new versions of Maya, it is colored differently. However, I recommend you to use an editor for MEL if you are not a New Maya Version Owner. This word is a function. It does a job. “print” function does the job of printing a text.

“Hello World” is necessary for the print function. Indeed it is a part of it. For watching a movie on a DVD player you need a DVD or CD, otherwise it is impossible to watch anything. Indeed “print” function could be defined like this:

It is a function that accepts a text and prints in the Maya Command Line.

Now I hope that you are satisfied with what you have learned. Keep in touch and be informed instantly as tutorials and other stuffs pop up hust by adding your email into our newsletter form.

Mostafa Talebi




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s