Wednesday, March 16, 2011

Week 2- Mel Commands Tutorial

In the Shelf menu, directly below the Status Line, a Maya user can save a script to bring it up conveniently later on. One way to accomplish this is to drag the highlighted code to the shelf area using the middle mouse button. Another way to accomplish this is to bring up the Script Editor and click File, then Save Script to Shelf.

This tutorial discusses how to attribute the manual commands and functions in Maya to the programmable ones in Mel. http://www.cgsutra.com/autodesk_maya_tutorials/mel/chapter_03/ch03_mel_command.php

1. Create sphere manually.
              - Create ---Pologon Primitives---Sphere Options Box
2. Mel code
             polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1;
             // Result: pSphere1 polySphere1 //
3. Breakdown of Script (directly related to the Sphere Options Box)
           - polySphere is a command to create the sphere object.
           -r = radius
           -sx = smaller increments of faces within the sphere along
            the x-axis
           -sy = smaller increments of faces within the sphere along   
            the y-axis 
           -ax = modeling axis for object- three dimensions follow it.
           -cuv= create uvs - takes a value of 1 or 2- 1 is related to pinched
             at the poles function and 2 is related to sawtooth at the
             poles function.
           -ch construction history button on or off.

The first line of code will work if the names of each flag are written in the extended format like -axis for -ax.

Mel contains three options for writing commands. The first, create, is used normally. The second, query, is to "inquire" about a certain piece of information about a produced object. The third, edit, can change the properties of any flag.

This is the code I experimented with and is also shown differently in the tutorial:

polySphere -query -axis;
// Error: No object was specified to query //
select -r pSphere1 ;
polySphere -query -axis;
// Result: 0 1 0 //

It turns out that I didn't have the sphere selected before I wanted to get information from it.

Operators work the same way in Mel as they do in regular math. Except that they are connected to types in Mel such as Integer, Floats, Vector, String, and Matrix. There are three operators such as binary, unary, and ternary. Binary operators must have two operands: $h>3, which would be $h and 3. Unary must have one operand : $h --, which is $h. Ternary related to true and false from the example in the tutorial, however, it was confusing.

No comments:

Post a Comment