Hello, if you got some time, can you try this code?
- Original diffuse texture extension is not important.
- Diffuse texture should be 'suffixless' or have the same suffix assigned in the script. (i.e. sword.tga or 'sword_DIFF.tga' if _DIFF is the desired suffix name).
- Actual files must exist in the same diffuse texture path.
- Added an extension too, in case you are using a .jpg but want to assign other types of extension files.
It doesn't have the original creator anywhere, it would be fair to put his name along with the script if you can find who was it?
try(destroyDialog ::renameMaps)catch()
rollout renameMaps "rename Maps"
(
local slots = #("Diffuse Map", "Specular Map", "Normal Map")
local sufix = #("_DIFF", "_SPEC", "_NORM")
local ext = ".tga"
local appendPath = pathConfig.appendPath
group " _Sufix : "
(
edittext et_diff "Diffuse :" pos:[10,25] width:180 height:17 text:sufix[1]
edittext et_spec "Specular :" pos:[10,45] width:180 height:17 text:sufix[2]
edittext et_norm "Normal :" pos:[10,65] width:180 height:17 text:sufix[3]
)
group "File Type"
(
edittext edt_fileType "File Type :" width:180 height:17 text:ext
)
group " Add && Rename : "
(
checkbox cb_spec "Add Specular Map" checked:on
checkbox cb_bump "Add Normal Bump" checked:on
spinner spn_amount "Bump Amount: " fieldwidth:60 range:[-999,999,100] type:#integer
)
button btn_doit "DO THE JOB!" width:192 height:35
on cb_bump changed state do spn_amount.enabled = state
on btn_doit pressed do
(
if selection.count == 0 then messageBox "Select Some Object!" title:"Warning" beep:off else
(
sufix = #(et_diff.text, et_spec.text, et_norm.text) ; array = #()
for node in selection where node.mat != undefined do
(
if (material = getClassInstances Standardmaterial target:node).count != 0 do
(
for mat in material where mat.filterMapAmount != 17 do
(
if mat.diffuseMap != undefined and isKindOf mat.diffuseMap bitmapTex do
(
local baseName = getFilenameFile mat.diffuseMap.filename
-- File could already contain the suffix, remove it.
if (matchPattern baseName pattern:("*" + sufix[1]) ignoreCase:true) then
(
baseName = substituteString baseName (sufix[1]) ""
)
mat.diffuseMap.name = baseName + sufix[1]
-- (Current extension of the file, not used)
local currExt = getFilenameType mat.diffuseMap.filename
local ext = edt_fileType.text
path = getFilenamePath mat.diffuseMap.filename
if cb_spec.checked and doesFileExist (file = appendPath path (baseName + sufix[2] + ext)) do
(
mat.specularLevelMap = Bitmaptexture name:(baseName + sufix[2]) fileName:file
)
if cb_bump.checked and doesFileExist (file = appendPath path (baseName + sufix[3] + ext)) do
(
mat.bumpMap = Normal_Bump normal_map:(Bitmaptexture name:(baseName + sufix[3]) fileName:file)
mat.bumpMapAmount = spn_amount.value
)
)
mat.filterMapAmount = 17
append array mat
)
array.filterMapAmount = 100
)
)
)
)
)
createDialog renameMaps 200 280 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
Replies
can be changed to
Not sure if those styles were there for 2009. I tried it on the oldest copy I had at work which was 2011 and it ran.
- Original diffuse texture extension is not important.
- Diffuse texture should be 'suffixless' or have the same suffix assigned in the script. (i.e. sword.tga or 'sword_DIFF.tga' if _DIFF is the desired suffix name).
- Actual files must exist in the same diffuse texture path.
- Added an extension too, in case you are using a .jpg but want to assign other types of extension files.
It doesn't have the original creator anywhere, it would be fair to put his name along with the script if you can find who was it?
Hope it works well!
(Expected behavior)