/* */

Tuesday 23 February 2010

MEL Commands

To comment a line out - usually a good idea to describe what the code is doing eg:

//This line will (purpose of the code)

Any line preceded by // will not be evaluated when run, and is a good way of stating the scripts funtion clearly, for debugging purposes.

Always terminate (end) a line with an ;

Variables and Data Types
Variables act as dynamic containers that acquire and store information according to the command assigned to it. Always preceded by a $ sign. Variables yeild different data types, eg (MEL equivalent in brackets)

1. Integers (int) - whole numbers
2. Floats (float)- Numbers with decimal places
3. Vectors (vector) - values derived from three numbers - such as position x8, y9, z4
4. Strings (string) - a collection of characters (words and numbers) eg psphere1
5. Arrays ([]) - Variables with more than 1 object are given a number (eg [1]) and can be reffered to. As seen in Nodes such as MultiplyDivide Node where more than one equation can be attached to the same node. I recall being stuck for days on a tutorial because it didn't have enough array slots, then I realise the only way of doing this was to add an array using MEL.

Variables allow for dynamic content, so their contnt will update accordingley.

//To write a variable:
$MyVariable

//You can give a variable any name it wants but it cannot start with a number eg:
$10Variable

*/This would be incorrect, the variable however can contain numbers after the first letter eg: */
$Variable10

Precede the variable with the data type eg:

int $myVariable - Variable can only contain whole numbers
string &myVariable - Variable can only contain characters (name of object) and must be encapsulated by "" eg "psphere1"
float $myVariable - Variable can have any number (including decimal places)
vector $myVariable - Variable contains a value that requires 3 numbers to delineate it eg colour (RGB) or position (xyz). Vector variables are storred within <<>> brackets. eg:
<<12, 87.59, 43>> Maya will automatically turn these values into float values eg:
<<12.0, 87.59, 43.0>>


Anything within `` marks (for instancel: `modelpanel -q -camera ($whichPanel)`;
means it will be evaluated.



Condition Syntax:
(other wise known as "if" or "else" statements)

< : less than
> : greater than
== equal to
!= not equal to
>= greater or equal to
<= less or

No comments:

Post a Comment