/* conformTextures.mel Creation Date: 8-5-99 Author: robin (robin@uberware.net) http://www.uberware.net/mel/ Description: allows scenes to work correctly on both IRIX and NT at the same time. Usage: conformTextures; Version: 1.0 Notes: If you open a scene created on one platform, just type this command to update the textures for the other. Also, place the text: conformTextures; in the pre-render MEL field of the render globals and your scene will render correctly on both platforms. Assumtions: this script assumes that you are cross mounting your disks (or at least maintain exact duplicate hierarchies). for example, if your IRIX box is the file server, and the NT always mounts the "/usr2" volume as drive "J:". In theory, if you don't mount the disks but use the "\\machine\drive" notation, it should work, but i haven't tested that. to customize the mapping, change the arrays at the beginning of the conformTextures procedure below. There should be one element in each array for each drive that is shared. Disclaimer: Use and modify at your own risk! */ // changes IRIX to NT or NT to IRIX format slashes for directories. proc string fixSlashes(string $name, string $os) { string $fromDir, $toDir; string $newName = $name; if ($os != "nt") { // on irix, change \ to / $toDir = "/"; $fromDir = "\\\\"; // it's a mess, cuz of special meanings for \ } else { // on nt, change / to \ $toDir = "\\"; $fromDir = "/"; } string $buf[]; // this is the number of slashes we're gonna have to replace int $tokens = tokenize ($newName, $fromDir, $buf); for ($i = 0; $i < $tokens; $i++) $newName = substitute ($fromDir, $newName, $toDir); print ("// conformed file: "+$newName+"\n"); return $newName; } // actually checks and conforms if found proc int doConform(string $item, string $s1, string $s2, string $os) { // get the old name string $filename = `getAttr ($item+".fileTextureName")`; string $from, $to; if ($os != "nt") { // on irix replace $s1 (nt) with $s2 (irix) $from = $s1; $to = $s2; } else { // on nt replace $s2 (irix) with $s1 (nt) $from = $s2; $to = $s1; } string $newName = $filename; string $subName = substring ($filename, 1, size($from)); // this should catch the fact that windows drive letters can be // either upper or lower case if ($os != "nt") $subName = toupper ($subName); string $postName = substring ($filename, size($from)+1, size ($filename)); if ($subName == $from) { // replace the name string $newName = $to + $postName; // then fix the slashes $filename = fixSlashes($newName, $os); setAttr ($item + ".fileTextureName") -type "string" $filename; return true; } return false; } // main entry point global proc conformTextures() { // CHANGE THESE FOR YOUR SYSTEM // the elements are the corresponding places where IRIX and NT // mount the disks // these two arrays must be the same size. string $irix[] = {"/usr2","/projects"}; string $nt[] = {"J:","K:"}; // note uppercase on NT drive letters if (size($irix)!= size($nt)) error "Cannot map all directories. Check the arrays in this script."; string $os = `about -os`; string $each; string $all[] = `ls -type file`; for ($each in $all) { int $fixed = false; // i do the looping here, cuz when i tried to put it in the check // proc, it crashed maya upon return (bug #117420) for ($check = 0; $check < size($irix); $check++) { // check name against next item; // order matters: nt should be first $fixed = doConform ($each, $nt[$check], $irix[$check], $os); // if it was fixed, stop checking if ($fixed) break; } // if none matched, change the slashes for good measure if (!$fixed) { // get old name string $filename = `getAttr ($each+".fileTextureName")`; // fix slashes string $newName = fixSlashes($filename, $os); // set new name setAttr ($each+".fileTextureName") -type "string" $newName; } } }