Beginners Guide to Mel

This is a beginners guide til Maya
s scripting language MEL. This is not a single tutorial but an ongoing guide that will grow. Later we will make a Novice and Advance guide.
Version: Wouz Production - Beginners Guide to Mel 0.0.3
Introduction
As you may already have guessed this guide is about AutoDesk Maya’s internal scripting language ”Mel”. Mel is short for Maya Embedded Language which was included in Maya from the very beginning. Mel looks a lot like C++ in that way the syntax and understanding is somewhat similar – but it’s in no way as potent. Mel should be easy for 3D artists to learn and use, but as I’m started as a programmer and later became a 3D artist I wouldn’t know about that

. You can’t find anything here (yet) you can’t find in the Maya Mel Commands help (Maya->Help->Mel commands), but I’ll try to make it easier to understand and make more examples. I don’t know where this guide is going to go or how/when it’s going end, for starters it will a mix of random pieces of cool code to a more in-depth explanation of what’s really going on.
Now, let’s get started…
Change log (sins version 0.0.2)
- A while loop example.
Note
There are no screenshots in this guide yet, it will come in a later version.
New to Mel? look here!
You need to bring up the script editor, this is where you write and execute your scripts. Write something like “polySphere” and press Ctrl-Enter, wola a brand new Polygon Sphere. I strongly advice you to use an external software/IDE when writing bigger scripts, as the script editor is very low tech regarding features like project management, syntax highlighting, code-folding, code-completion etc.
Table Of Contents
- 1.0 - Selection
- 2.0 - Loops
1.0 - Selection
select "*";
A little evil “trick” – eat up all your RAM and crash (don’t try this at home, my Core 2 64bit 4GB system got slammed): Select everything as before. Go to the Hypergraph->graph->Indput and Output Connections. Maya will try to show you all the nodes and connections that are behind the engine in a default, supposedly empty, scene. Die Maya Die!
select "*";
hyperGraphWindow "" "DAG";
hyperGraph -e -down hyperGraphPanel1HyperGraphEd;
2.0 - Loops
Loops runs one or more commands one or several times. Loops are often (always) used to iterate through arrays, something as simple as counting to 100 is easily done by looping.
2.1 - For Loop
for ($i=1; $i <= 100; $i++) {
print ("value : " + $i + "n");
}
This for loop contains 4 interesting elements. the "$i=1", "$i <= 100", "$i++" and the print command with the $i in. First of the $i is a variable which will be covered later on. $i is set to a value of 1 that will be counted up to 100 by the $i++ (increasest the $i value with 1, eg. 14 + 1 = 15 and so on). when $i reaches 100 it will end the loop, the loop continues as long as $i is smaller or equals 100. The last, print $i printes the value of $i. When $i reaches 101 the loop will not run, the value of 101 will not be printed since the loop breaks without entering the loop. 2.2 - While Loops
2.2 While
while ($count < 100 ) {
print "Hello Mel Worldn";
}
- 02.12.2006. 23:18 | Author: Cesboa
Comments
This article hasn't been commented yet.
Write a comment