/* This file downloaded from Highend3d.com ''
'' Highend3d.com File Information: ''
'' Script Name: FileTextureManager '' Author:
'' Last Updated: Nov 18, 2008 '' Update/Change this file at:
'' http://Highend3d.com/maya/downloads/mel_scripts/rendering/misc/1012.html ''
'' Please do not alter any information above this line
'' it is generated dynamically by Highend3d.com and will '' be changed automatically on any updates. */
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// ///
/// Procedure Name : FileTextureManager ///
/// Updated : July 10, 2007 /// In celebration of Hongkong's returning to China for ten years. ///
/// Author : Crow Yeh
/// Contact : crow@citiz.net ///
/// History : /// v3.3 Fixed a bug that dselects needed file nodes when user checks /// checkBoxes not supposed to be checked. /// v3.2 Fixed a bug that fails to recognise '\\' as path separator /// under OS other than Windows. /// Extra functions now supports mentalray. /// v3.1 Adds support (only basic functions) for Maya /// psdFileTex node type and mentalray mentalRayTexture /// node type. ///
/// Description : /// /// File Texture Manager works on Windows/IRIX/Linux/MAC, manages file textures in a handy way. /// FTM's basic functions: /// 1. Analyse scene file textures and give texture existence report. /// 2. Copy or move the original texture files to user defined path (customizable). /// 3. Update file textures' path info. /// 4. Handle path strings. eg. replace string, add prefix, append suffix...
/// /// FTM's extra fuctions: /// 1. Substitute file texture's path root string. eg. redirecting sourceiamges... /// 2. Memory efficiency setup for textures. (BOT for Maya and .map for mentalray.) /// 3. Filter type batch set. /// 4. Texture file format conversion. ///
/// How to use : /// /// Put the script in your scripts folder then start Maya. Type /// and execute \/// Editor, an UI window will appear. Then follow the help in the UI /// window to finish your job. Have fun! ///
/// Inputs : None ///
/// Return : None ///
/// All Rights Reserved .
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
///////////////////
// SCRIPT Starts // ///////////////////
///////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// //
// Procedure to check selection //
proc int FTM_SelCheck(string $nodes[]){ int $sel = 0; if (size($nodes)) $sel = 1; else confirmDialog -t \Texture Manager\-m \least one file texture node must be selected!\return $sel; }
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
//
// Procedure to remind user that job finished. //
proc FTM_END(){ confirmDialog -t \details.\}
///////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// //
// Procedure to give logs //
proc FTM_Log (string $type, string $node, string $log) { string $finLog; if (size($node)) $log = $node + \else $log = \switch ($type) { case \ $finLog = \***********************************\\n\\ File Texture Manager Log starts...\\n\\
***************************************************************************************************************\\n\ break; case \ $finLog = \*********************************\\n\\ File Texture Manager Log ends...\\n\\
***************************************************************************************************************\\n\ break; default: $finLog = $log; break; }
print $finLog; }
/////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////// //
// Get the right format of path(folder) to match current OS. //
proc string FTM_GetPath (string $FTM_FileOrPath, string $FTM_OldPath) //$FTM_FileOrPath Input type: file or path //$FTM_OldPath The input { //Do not use 'fromNativePath' here //that only works on Windows! $FTM_OldPath = `substituteAll \ //Only want the path. if ($FTM_FileOrPath == \ $FTM_OldPath = `dirname $FTM_OldPath`; //Get rid of the slash at the end. $FTM_OldPath = `substitute \ //Get the right path. string $FTM_RightPath = `toNativePath ($FTM_OldPath + \ return $FTM_RightPath; }
///////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// //
// Get the right format of input file's fullname (including path) to match current OS. // Return a string array, the first element is the right format of the input file's
// fullname (including path), the second element is the shortname of input file (without path). //
proc string[] FTM_GetFile (string $FTM_OldFullPath) { string $FTM_RightPath[]; string $FTM_PathElements[]; int $FTM_PathElementsSize; // fullname $FTM_OldFullPath = `substituteAll \ $FTM_RightPath[0] = `toNativePath $FTM_OldFullPath`; $FTM_PathElementsSize = `tokenize $FTM_OldFullPath \ $FTM_RightPath[1] = $FTM_PathElements[$FTM_PathElementsSize - 1]; return $FTM_RightPath; }
///////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// //
// Analyse all the file texture nodes in current scene. //
proc string[] FTM_FileTextureAnalyst () {
// All the file texture nodes maybe point to texture files in different paths(folders).
// Here I use \// different paths if the file texture nodes point to files in n different paths.
// The trick is to have an string array $FTM_Groups[], within which every element has corresponding
// path and nodes pointing to that path are concatenated togather with a \to appear in path or name.
// Every element has a form style of \
// Leave $FTM_Groups[0] for empty path, which means node's texture file was not specified.
// Leave $FTM_Groups[1] for files without path, which means only texture file's short name was presented but path info was missing. // All the file texture nodes found in current scene. global string $lsCmd; string $FTM_Files[] = eval($lsCmd); // Different groups. string $FTM_Groups[]; int $FTM_GroupsSize; if (size($FTM_Files)){ $FTM_Groups[0] = \ $FTM_Groups[1] = \ } // Figure out how many \ // into proper \ for ($eachFile in $FTM_Files) { $FTM_GroupsSize = size($FTM_Groups); // Get the path of current file texture node string $FTM_CurrentFullPath = substituteAll (\`getAttr ($eachFile + \ string $FTM_CurrentPath = dirname ($FTM_CurrentFullPath); // File texutre was specified. if (size($FTM_CurrentPath)) { // Compare current path to all \current node