QQ聊天

关于Max贴图路径的重新查找指定

这个范例只是演示基本需要的东西,本身速度并不好并且只是针对单个Max文件操作。有需要的人自己修改。

此外,用相对路径可以完全避免此类问题,有兴趣的看这里

http://www.cnblogs.com/sitt/archive/2011/03/31/1989846.html

View Code
Fn SetDirectoryAccessControlType inputDirectoryInfo =
(
tempUserName
= (DotNetClass "System.Environment").UserName
fileSystemRights
= (DotNetClass "System.Security.AccessControl.FileSystemRights").Modify
accessControlType
= (DotNetClass "System.Security.AccessControl.AccessControlType").Allow
fileSystemAccessRule
= DotNetObject "System.Security.AccessControl.FileSystemAccessRule" tempUserName fileSystemRights accessControlType
directorySecurity
= inputDirectoryInfo .GetAccessControl()
directorySecurity.AddAccessRule fileSystemAccessRule
inputDirectoryInfo .SetAccessControl directorySecurity
)

Fn GetAllFiles targetPath fileFilter
=
(
local SearchOption,DotNetDirectoryInfo
SearchOption
= DotNetClass "System.IO.SearchOption"
DotNetDirectoryInfo
= DotNetObject "System.IO.DirectoryInfo" targetPath
SetDirectoryAccessControlType DotNetDirectoryInfo
result
= for tfi in (DotNetDirectoryInfo.GetFiles fileFilter SearchOption.AllDirectories) collect tfi.FullName
result
)

Fn GetStringParseCount inputString1 inputString2
=
(
result
= 0
referenceString
= inputString1
if inputString1.count > inputString2.count do referenceString = inputString2
for i = 0 to referenceString.count - 1 do
(
if inputString1[inputString1.Count - i] == inputString2[inputString2.Count - i] then
(
result
+= 1
)
else
(
exit
)
)
result
)

Fn GetRootTrackNode
= (refs.Dependents RootNode)[1]

Fn RecursionProcessFilePath inputTargetNode inputNewPath
=
(
for i = 1 to inputTargetNode.numSubs do
(
tempSubAnim
= getSubAnim inputTargetNode i
tempNode
= (getSubAnim inputTargetNode i).object
if ClassOf tempNode == Bitmaptexture do
(
oldFileFullName
= tempNode.FileName
if oldFileFullName != "" and not DoesFileExist oldFileFullName do
(
oldFileName
= FilenameFromPath oldFileFullName
newFilelist
= GetAllFiles inputNewPath oldFileName
maxParseFileName
= ""
for tempFileName in newFilelist where
(
GetStringParseCount tempFileName oldFileName
> GetStringParseCount tempFileName maxParseFileName
)
do
(
maxParseFileName
= tempFileName
)
if maxParseFileName != "" do tempNode.FileName = maxParseFileName
)
)
if tempSubAnim.numSubs > 0 do RecursionProcessFilePath tempSubAnim inputNewPath
)
)
newPath
= GetSavePath()
if undefined != newpath do RecursionProcessFilePath (GetRootTrackNode()) newPath

posted @ 2011-06-16 12:14  SITT  阅读(2298)  评论(0编辑  收藏  举报
QQ聊天