maya贴图路径找回脚本.doc_第1页
maya贴图路径找回脚本.doc_第2页
maya贴图路径找回脚本.doc_第3页
maya贴图路径找回脚本.doc_第4页
maya贴图路径找回脚本.doc_第5页
已阅读5页,还剩42页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

/* This file downloaded from H H File Information: Script Name: FileTextureManager Author: Last Updated: Nov 18, 2008 Update/Change this file at: http:/H/maya/downloads/mel_scripts/rendering/misc/1012.html Please do not alter any information above this line it is generated dynamically by H and will be changed automatically on any updates.*/ Procedure Name :FileTextureManager/ Updated :July 10, 2007/In celebration of Hongkongs returning to China for ten years./ Author :Crow Yeh/ Contact :/ History :/v3.3Fixed a bug that dselects needed file nodes when user checks/checkBoxes not supposed to be checked./v3.2Fixed a bug that fails to recognise as path separator/under OS other than Windows./Extra functions now supports mentalray./v3.1Adds 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./FTMs 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./FTMs extra fuctions:/1. Substitute file textures 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 executeFileTextureManager in command line or Script/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;elseconfirmDialog -t File Texture Manager -m At least one file texture node must be selected! -b OK;return $sel;/ Procedure to remind user that job finished./proc FTM_END()confirmDialog -t File Texture Manager -m Job finished.nRefer to Script Editor for details. -ma center -b OK;/ Procedure to give logs/proc FTM_Log (string $type, string $node, string $log) string $finLog;if (size($node)$log = $node + n;else$log = t + $log + n;switch ($type) case start:$finLog = n*nFile Texture Manager Log starts.n*n;break;case end:$finLog = *nFile 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_FileOrPathInput type: file or path/$FTM_OldPathThe input/Do not use fromNativePath here/that only works on Windows!$FTM_OldPath = substituteAll $FTM_OldPath /;/Only want the path.if ($FTM_FileOrPath = file)$FTM_OldPath = dirname $FTM_OldPath;/Get rid of the slash at the end.$FTM_OldPath = substitute /*$ $FTM_OldPath ;/Get the right path.string $FTM_RightPath = toNativePath ($FTM_OldPath + /);return $FTM_RightPath;/ Get the right format of input files fullname (including path) to match current OS./ Return a string array, the first element is the right format of the input files/ 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_OldFullPath /;$FTM_RightPath0 = toNativePath $FTM_OldFullPath;$FTM_PathElementsSize = tokenize $FTM_OldFullPath / $FTM_PathElements;$FTM_RightPath1 = $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 group to indicate different paths , which means there are n groups of/ 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 *, which is not supposed to appear in path or name./ Every element has a form style of path*node1*node2*node3./ Leave $FTM_Groups0 for empty path, which means nodes texture file was not specified./ Leave $FTM_Groups1 for files without path, which means only texture files 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_Groups0 = FTM_EmptySocket_FTM;$FTM_Groups1 = FTM_MissingPathSocket_FTM;/ Figure out how many groups there are in current scene, and put each file texture node/ into proper group.for ($eachFile in $FTM_Files)$FTM_GroupsSize = size($FTM_Groups);/ Get the path of current file texture nodestring $FTM_CurrentFullPath = substituteAll (, getAttr ($eachFile + .fileTextureName), /);string $FTM_CurrentPath = dirname ($FTM_CurrentFullPath);/ File texutre was specified.if (size($FTM_CurrentPath)/ Compare current path to all groups have been found. If matches then append current node/ to current group and exist the compare loop immediately./ Remember that socket 0 is kept for nodes without texture file specified/ Remember that socket 1 is kept for nodes with texture file specified but with the path info missingfor ($j=2; $j= $FTM_GroupsSize)/ Create a new group and append current file texure node.$FTM_Groups$FTM_GroupsSize = $FTM_CurrentPath + * + $eachFile;continue;/ File texture was specified but the path info was missingelse if (size($FTM_CurrentFullPath)string $tmp = $FTM_Groups1;$tmp += * + $eachFile;$FTM_Groups1 = $tmp;/ File texture was not specified yet. Append current node to the first socket of groupselsestring $tmp = $FTM_Groups0;$tmp += * + $eachFile;$FTM_Groups0 = $tmp;select -cl;return $FTM_Groups;/ Edit the UI Controls after theyve been built/proc FTM_EditUIControl (string $FTM_OptionColumn, string $FTM_HelpForm)/ Operation moderadioButtonGrp -e -on1 (textFieldButtonGrp -e -en 0 -tx + $FTM_OptionColumn + |FTM_SourceDirectoryField)-on2 (textFieldButtonGrp -e -en 1 -tx + $FTM_OptionColumn + |FTM_SourceDirectoryField)($FTM_OptionColumn + |FTM_OperationMode);/ Set source directorytextFieldButtonGrp -e -bc (FTM_BrowseCmd file + $FTM_OptionColumn + |FTM_SourceDirectoryField Set_S.D. 0)($FTM_OptionColumn + |FTM_SourceDirectoryField);/ Set target directorytextFieldButtonGrp -e -bc (FTM_BrowseCmd path + $FTM_OptionColumn + |FTM_TargetDirectoryField Set_T.D. 4)($FTM_OptionColumn + |FTM_TargetDirectoryField);/ Make new foldercheckBoxGrp -e -on1 (textFieldGrp -e -en 1 -text + $FTM_OptionColumn + |FTM_NewFolderNameField)-of1 (textFieldGrp -e -en 0 -text MyTextureFiles + $FTM_OptionColumn + |FTM_NewFolderNameField)($FTM_OptionColumn + |FTM_MakeFolderChecker);/ Add prefixcheckBox -e -onc (textField -e -en 1 -text + $FTM_OptionColumn + |FTM_AddPrefixRow|FTM_PrefixField)-ofc (textField -e -en 0 -text prefix_ + $FTM_OptionColumn + |FTM_AddPrefixRow|FTM_PrefixField)($FTM_OptionColumn + |FTM_AddPrefixRow|FTM_AddPrefixChecker);/ Add suffixcheckBox -e -onc (textField -e -en 1 -text + $FTM_OptionColumn + |FTM_AddSuffixRow|FTM_SuffixField)-ofc (textField -e -en 0 -text _suffix + $FTM_OptionColumn + |FTM_AddSuffixRow|FTM_SuffixField)($FTM_OptionColumn + |FTM_AddSuffixRow|FTM_AddSuffixChecker);/ Replace stringcheckBoxGrp -e -on1 (textFieldGrp -e -en 1 -text + $FTM_OptionColumn + |FTM_OldStringField; textFieldGrp -e -en 1 -text + $FTM_OptionColumn + |FTM_NewStringField)-of1 (textFieldGrp -e -en 0 -text OldString + $FTM_OptionColumn + |FTM_OldStringField; textFieldGrp -e -en 0 -text NewString + $FTM_OptionColumn + |FTM_NewStringField)($FTM_OptionColumn + |FTM_ReplaceStringChecker);/ Help description fieldstring $FTM_HelpDescription = nDescription:n;$FTM_HelpDescription += File Texture Manager works on Windows/IRIX/Linux/MAC, manages file textures in a very handy way.n;$FTM_HelpDescription += FTM basic functions:n;$FTM_HelpDescription += 1. Analyse scene file textures.n;$FTM_HelpDescription += 2. Copy or move the original texture files to user defined path.n;$FTM_HelpDescription += 3. Update file textures path.n;$FTM_HelpDescription += 4. Mentalray texture node is supported too.n;$FTM_HelpDescription += FTM extra functions:n;$FTM_HelpDescription += 1. Substitute file texture paths root string. eg. redirecting sourceiamges.n;$FTM_HelpDescription += 2. Memory efficiency setup/unset for file textures according to their resolution. Textures larger than Threshold (in either x or y) will be set to use renderer prefered format (BOT for Maya and .map for mentalray) in setup mode. Corresponding memory-efficient file will be automatically generated if needed. When unset, all textures smaller than threshold in both x and y will be set to use normal textures, from which file the memory efficient texture was generated. BOT unset assume normal texture exist in the same directory. Mentalray .map unset will first check if the normal texture exist. If not, FTM will try to extract one from the .map file. Nodes pointing to sequences will be ignored.n;$FTM_HelpDescription += 3. Set filter type to specified type for selected file nodes.n;$FTM_HelpDescription += 4. Convert texture file format from From to To for selected file nodes. If From is not *, only file nodes whose texture files format match From will be handled. For file nodes use image sequence as texture files, the range for conversion need to be specified, so only print out corresponding commands instead of really do the jobs. This function use Maya imgcvt and mentalray imf_copy ultility to do the conversion, so make sure them can be found in system executable path.nn;$FTM_HelpDescription += Work Flow:n;$FTM_HelpDescription += Step 1. Analyse scene file textures.(optional)n;$FTM_HelpDescription += Step 2. Select scene file textures (nodes) you want to manage by checking on the related checkers in the UI. You can also do this by your own method, Eg. select them in Hypershade.n;$FTM_HelpDescription += Step 3. Set options as needed.n;$FTM_HelpDescription += Step 4. Do copy, move or set by pressing related button.nn;$FTM_HelpDescription += Tips:n;$FTM_HelpDescription += 1. Always keep 2 different version for each texture file. Eg. abc_LowRes.tga is in low resolution while abc_HighRes.tga is in high resolution. Do your job using low-res textures to speed the interactant. Just remember to use FileTextureManager to reset each file texture to point to the related high-res texture before rendering. (Add prefix, add suffix or even replace string.)n;$FTM_HelpDescription += 2. The FileTextureManagers UI does not update dynamically like what Attribute Editor does, so it is better to re-analyse scene file textures each time you finish an FTM job. This is not necessary if you do not use the Analyse function at all.nn;$FTM_HelpDescription += Notes:n;$FTM_HelpDescription += 1. Final target directory will be equal to target directory plus new folder, if user decide to make a new folder.n;$FTM_HelpDescription += 2. Add suffix function has limitation on the texture file name. To be sure it work as desired, the file name must be in a regular format, Eg. filename.ext, filename.#.#.ext, filename.ext.#.#, etc.n;$FTM_HelpDescription += 3. Add prfix, add suffix and replace string can be executed at the same time to each file texture. Replace string is caculated first, then add suffix, and add prefix last.n;$FTM_HelpDescription += 4. It is highly recommended not to contain . in prefix, suffix, old string and new string.n;$FTM_HelpDescription += 5. Sometimes process fails. The reason may be various. The most possible reason could be one of or both the following two: a. Texture file is not found in the source directory; b. Permission denied on reading or writing or deleting.nn;$FTM_HelpDescription += Details:n;$FTM_HelpDescription += 1. Analysing scene file textures let you know how many file textures there are in the scene, where there are, whether they exist or not, etc. It also allows user select all the texture files point to same path by only one simple click.n;$FTM_HelpDescription += 2. How to choose operation mode depends on different source directory status. If file is there where it point to, use Automatic mode, otherwise use Manual mode.n;$FTM_HelpDescription += 3. Other functions are pretty definite as marked in the UI.n;scrollField -e -text $FTM_HelpDescription ($FTM_HelpForm + |FTM_HelpField);/ judge if the input string is format extension, sequence or just part of file basename/proc int FTM_FCWhatIs(string $string)int $isWhat;/ 0 - format extension/ 1 - sequence number/ 2 - nothing, is just file basename/ 3 - botglobal string $FTM_FCAllFormats;$string = tolower($string);if (stringArrayCount($string,$FTM_FCAllFormats)$isWhat = 0;else if (size(match(0-9*,$string) = size($string)$isWhat = 1;else if ($string = bot)$isWhat = 3;else$isWhat = 2;return $isWhat;/ judge texture file format, only according to the possible extension name/proc string FTM_FCFileRegularName(string $file)$file = substituteAll (, $file, /);string $fileRegularName = stringToStringArray(basename($file,),.);/ try to make it like below/ 0 - file name/ 1 - the sequency number if presented, or / 2 - the extension if pres

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论