/* toi_fixIES.mel * * Mentalray IES Fix for renderfarm jobs * * Author: T. Welman, TOI TU Delft, january 2010 * version 1.0 * * Maya doesn't update the location of IES files relative to the project path upon loading * of a scene. * Whenever you submit a job to a renderfarm, this may cause problems, because the path * is no longer valid. * This script is intended to be placed into the mel directory of your project * and toi_fixIES() ahould be called as a pre-render MEL command (Render Settings, Common) * * Note that the IES files MUST be in the sourceimages folder, * consist of characters a-z, Z-A, 0-9, - and _ * and have the extension ".ies" * * Usage: * 1. Place in the MEL folder of your project, named toi_fixIES.mel * 2. set toi_fixIES() as pre-render MEL command * * Note: You MUST make sure the name of the script file and the procedure are the same! * */ global proc toi_fixIES () { string $iesNodes[] = `ls -type "mentalrayLightProfile"`; string $t; string $projectpath = `workspace -q -rd`; string $srcImgDir = toi_addTrailingSlash(toi_getProjectLocation("sourceImages")); for ( $t in $iesNodes ) { if ( `getAttr ($t+".fileName")` != "" ) { string $ies = `getAttr ($t + ".fileName")`; string $iesfile = `match ($srcImgDir+"[a-zA-Z0-9_\-\ ]+\.ies") $ies`; if ( $iesfile == "" ) { warning ("toi_mr_ies_fix(): Unable to determine relative ies file location for node " + $t + "\n"); } else { $ies = ($projectpath + $iesfile); print ("toi_fixIES() set the IES file for "+$t+" to: " + $ies + "\n"); setAttr -type "string" ($t + ".fileName") $ies; } } } } global proc string toi_getProjectLocation( string $what ) { // retrieves the project subdir for a specific item from the current workspace // eg: "scene" or "sourceImages" string $data[]; if ( $what == "scene" ) { $data = `workspace -q -ot`; } else { string $rt[] = `workspace -q -rtl`; if ( stringArrayContains( $what, $rt ) ) { $data = `workspace -q -rt`; } else { // not rendertpe? must be filerule then $data = `workspace -q -fr`; } } int $i; for ($i = 0 ; $i < size($data); $i+=2 ) { if ($data[$i] == $what ) { return $data[$i+1]; } } return ""; } global proc string toi_addTrailingSlash ( string $s ) { //adds a trailing slash if not present int $p = size($s); if ( substring($s,$p,$p) != "/" ) { $s +="/"; } return $s; }