// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // Given the psdFileTex node $node, convert the corresponding PSD file to // IFF and return the full path of the new file. If this is for export, // store the file in the project directory, otherwise, store in the disk // cache to be deleted after maya exits // global proc string doPsdToIffConversion(string $node, int $isExport) { string $format = "iff"; string $fileName = `getAttr ($node + ".fileTextureName")`; // If the file name is empty, psdExport will crash. // Prevent the crash and return early. if ($fileName == "") return ""; // expand environment variables and check for existence $fileName = `file -q -expandName $fileName`; if (!`file -q -exists $fileName`) return ""; // for .mi export we write and retain iff file on disk(under "projects/mentalRay/") // string $outDir = ""; if ($isExport == true) { $outDir = miGetRootDir(); } else { // non UI mode(batch rendering) also creates tmpDiskCache folder // in tmp folder, so it should be available all the time // we delete these files after maya quits $outDir = `diskCache -tempDir`; } if ($outDir == "") return ""; if ($isExport == true ) { // .mi export $outDir += "/psdExport/"; } else { // Interactive, non UI(batch rendering) or IMR $outDir += "/tempPsd/"; } string $inFileName = $fileName; string $outFileName = basenameEx($fileName); string $lsn = `getAttr ($node + ".layerSetName")`; // Bug #203143 // Because mental ray for maya does not support psd directly, // mental ray for maya does not detect changes in layer and alpha settings in the psd node during imr. // We want to include the alpha settings in the file name // so that imr can detect the psd node changes through the file name. string $alphaChannelName = `getAttr ($node + ".alpha")`; // Photoshop starts "Additional Alpha Channels at index 0, unlike the // psdFileTextureNode which starts them at 2, also, default is -1 in PS int $acidx = -1; if ($alphaChannelName != "Default") { string $channels[] = `getAttr ($node + ".alphaList")`; for ($i=0; $i -1) { $cmd += ("-aci " + $acidx); } if (catch(eval($cmd))) return ""; return $finalFileName; }