Maya

MEL: Find and edit the source of a procedure

Tuesday, September 23rd, 2008

The following script opens a MEL file in a text editor by checking where queried procedure is stored. As an example Notepad is used for Windows and Nedit for Linux.
Usage:
edit “procname”
Limitations:
The script only finds global procedures that have already been sourced

global proc edit( string $file ) {

    string $result = `whatIs $file`;

    string [...]

MEL: Setting the value of a Slim attribute

Friday, July 11th, 2008

Setting the value of a Slim attribute, from MEL, requires a bit more overhead compared to the normal Maya attribute. The following example shows how it can be done.

string $palette = `slimcmd slim FindPalette “MYPALETTE”`;

string $all = `slimcmd $palette GetAppearances`;

string $shaders[];

tokenize( $all, " ", $shaders );

 

for ( $s in $shaders ) {

    string $attr [...]

MEL: Setting the color for multiple lights

Friday, May 16th, 2008

Here’s a snippet if you want to set the RGB color for multiple lights at once.

colorEditor;

if (`colorEditor -query -result`) {

    string $lights[] = `ls -sl -dag -type light`;

    float $values[];

    $values = `colorEditor -query -rgb`;

 

    for ( $l in $lights ) {

        setAttr ($l + ".color") -type double3 [...]

MEL: Look through Light or Camera

Wednesday, May 14th, 2008

As a Lighting TD I find myself often having to look through different lights to position them correctly in the scene. Here’s a MEL procedure for opening the light (or camera) in a seperate window.
Usage: lookThrough( `ls -sl` );

proc lookThrough( string $selection[] ) {

    string $shapeType[] = `listRelatives -shapes $selection[0]`;

    string $type = [...]