----------------收集所有场景文件到同一目录下------------------
try(destroyDialog test)catch()
rollout test "资源收集工具"
(
button setpath ".........." pos:[12,75] width:60 height:25
button help "?" pos:[310,135] width:15 height:15
button setziptextrue "处理ZIP包内贴图为绝对路径" pos:[12,125] width:180 height:20
button getalltogether "( 0●︶ω︶●0 )--------@开始收集@-------( ╮(╯▽╰)╭~ )" pos:[12,20] width:300 height:45
label lab1 "<[email protected]>" pos:[220,128] color:red
edittext displaypath fieldWidth:225 labelOnTop:true pos:[85,80] readOnly:true text:"功能---将MAX文件及贴图收集到同一目录"
groupBox grp4 "" pos:[6,2] width:315 height:110
local commonfileSavepath
on help pressed do
(
w = newscript()
help01="处理ZIP包内贴图为绝对路径:把相对路径改为绝对路径
........:设置保存路径
( 0●︶ω︶●0 )--------@开始收集@-------( ╮(╯▽╰)╭~ ):收集所有文件到设置的路径内
?:帮助文件"
print help01 to:w
)
------------处理ZIP贴图的相对路径为绝对路径--------------
on setziptextrue pressed do
(
getmaxpath = maxFilepath
try
(
for r in objects where superclassof r == GeometryClass do
(
if classof r.material == Multimaterial then
(
material_number = r.material.count
for s = 1 to material_number do
(
tempstring =""
gettextruepath = r.material[s].diffusemap.filename
filterstringarray = filterstring gettextruepath "\\"
for i = 2 to (filterstringarray.count) do tempstring+=filterstringarray[i]+"\\"
tempstring
tempstring01 = getmaxpath+tempstring
get_textruepath = substring tempstring01 1 (tempstring01.count-1)
r.material[s].diffusemap.filename = get_textruepath
)
)
else
(
tempstring =""
gettextruepath = r.material.diffusemap.filename
filterstringarray = filterstring gettextruepath "\\"
for i = 2 to (filterstringarray.count) do tempstring+=filterstringarray[i]+"\\"
tempstring
tempstring01 = getmaxpath+tempstring
get_textruepath = substring tempstring01 1 (tempstring01.count-1)
r.material.diffusemap.filename = get_textruepath
)
)
)catch()
messagebox "打包的贴图已经绝对路径化了,最好你还是检查下是否我做的有疏漏"
)
--------------设置新的路径---------------------------
on setpath pressed do
(
commonfileSavepath = getSavepath()
displaypath.text = "路径:"+commonfileSavepath as string
)
---------------拷贝MAX文件和贴图到同一目录-----------------
on getalltogether pressed do
(
try
(
for i in objects where superclassof i == GeometryClass do
(
if classof i.material == Multimaterial then
(
material_number = i.material.count
for z = 1 to material_number do
(
getbitmap_name = getfilenamefile i.material[z].diffusemap.filename
getbitmap_type = getfilenametype i.material[z].diffusemap.filename
get_oldbitmappath = i.material[z].diffusemap.filename
set_newbitmappath = commonfileSavepath+"\\"+getbitmap_name+getbitmap_type
copyfile get_oldbitmappath set_newbitmappath
i.material[z].diffusemap.filename = set_newbitmappath
)
set_newmaxfile = commonfileSavepath+"\\"+maxFileName
savemaxfile set_newmaxfile
messagebox "累死我了,终于干完活了,现在打开的是你另存的MAX文件,注意是TEMPXXX.max"
)
else
(
getbitmap_name = getfilenamefile i.material.diffusemap.filename
getbitmap_type = getfilenametype i.material.diffusemap.filename
get_oldbitmappath = i.material.diffusemap.filename
set_newbitmappath = commonfileSavepath+"\\"+getbitmap_name+getbitmap_type
copyfile get_oldbitmappath set_newbitmappath
i.material.diffusemap.filename = set_newbitmappath
set_newmaxfile = commonfileSavepath +"\\"+ maxFileName
savemaxfile set_newmaxfile
messagebox "累死我了,终于干完活了"
)
)
)catch()
)
)
createdialog test 325 150