« Welcome | Home | Save Our Soho »

MEL: Look through Light or Camera

By nikos | May 14, 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[] ) {
  1.     string $shapeType[] = `listRelatives -shapes $selection[0]`;
  2.     string $type = nodeType( $shapeType[0] );
  3.  
  4.     if ( $type == "spotLight" || $type == "areaLight" || $type == "volumeLight" || $type == "camera" || $type == "directionalLight" ) {
  5.         string $wndName = "";
  6.         string $cmdStr;
  7.         string $whichPanel = `getPanel -withLabel $selection[0]`;
  8.         string $panelType = "modelPanel";
  9.         string $panelLabel = $selection[0];
  10.  
  11.         $wndName = $whichPanel + "Window";
  12.  
  13.         if ("" != $whichPanel) {
  14.             if (`panel -q -to $whichPanel`) {
  15.                 showWindow $wndName;
  16.             }
  17.             else {
  18.                 $cmdStr = ($panelType + " -e -to " + $whichPanel);
  19.                 eval $cmdStr;
  20.             }
  21.         }
  22.         else {
  23.             $cmdStr = ($panelType + " -l \""+ $panelLabel +"\" -to;");
  24.             eval $cmdStr;
  25.             $whichPanel = `getPanel -withLabel $selection[0]`;
  26.         }
  27.         lookThru $whichPanel $selection[0];
  28.     }
  29. }

Topics: Maya | No Comments »

Comments are closed.