ScriptSpot is a diverse online community of artists and developers who come together to find and share scripts that empower their creativity with 3ds Max. Our users come from all parts of the world and work in everything from visual effects to gaming, architecture, students or hobbyists.
--Script to rename paths of bitmap textures in a scene.try(destroyDialog ro_bmRename)catch()
rollout ro_bmRename "Single edit Bitmap filepaths or do a search & replace on all (case insensitive)" width:906 height:495(
local arrBMs = #()
local arrPaths = #()
combobox cbx_bm "Bitmap Filepaths" pos:[6,5] width:890 height:31
button btn_get "Get Bitmaps in Scene" pos:[5,449] width:124 height:40
checkbutton ckb_edit "Enable Edit" pos:[134,449] width:140 height:40
edittext edt_s "Search for:" pos:[323,450] width:439 height:16 enabled:false
edittext edt_r "Replace with: " pos:[323,472] width:439 height:16 enabled:false
button btn_rep "Do for All" pos:[769,449] width:132 height:40 enabled:false
button btn_swap "Swap" pos:[279,449] width:40 height:40
fn update_list=
(
arrBMs = #()
arrPaths = #()
arrCoronaBMs = getClassInstances coronaBitmap
for o in arrCoronaBMs do append arrPaths o.filename
arrBMs = getClassInstances bitmapTexture
for o in arrBMs do append arrPaths arrBMs[i].filename
cbx_bm.items = arrPaths
)--end fn
on cbx_bm entered txt do(if ckb_edit.checked do(
arrBMs[cbx_bm.selection].filename = txt
update_list())--end if)--end on
on btn_get pressed do(
update_list())--end on
on ckb_edit changed state do(if state then
(
edt_s.enabled = true
edt_r.enabled = true
btn_rep.enabled = true)--end ifelse(
edt_s.enabled = false
edt_r.enabled = false
btn_rep.enabled = false)--end else)--end
on btn_swap pressed do(
temp = edt_s.text
edt_s.text = edt_r.text
edt_r.text = temp
)--end on
on btn_rep pressed do(
local searchFor = edt_s.text
local replaceWith = edt_r.text
if searchFor != "" AND replaceWith != "" then
(--loop through object names:for i=1 to arrBMs.count do(
local startIndex = findString arrBMs[i].fileName searchFor -- returns the starting index of the found stringif startindex != undefined do(-- replace the string at "startIndex" with length of "searchFor.count" with "replaceWith"
arrBMs[i].fileName = (replace arrBMs[i].fileName startIndex searchFor.count replaceWith))--end if)--end for
update_list())--end ifelse displayTempPrompt ">>>>>> Fill in what to search for and what to replace with! <<<<<<<"5000)--end on)
createDialog ro_bmRename[\code]
I re-read 2-3 times the original question: "I want to rename the textures, and the link of texture should be keep!" and looks like all replies below are about Relinking texture #FileNames.
--Here is 2 staffs:
<TextureMap>.name
assignNewName <TextureMap>
And as you say "the texture name is not correct", then give more details about.
Dont really know if this is what you want but maybe it helps:
--Script to rename paths of bitmap textures in a scene.try(destroyDialog ro_bmRename)catch()
rollout ro_bmRename "Single edit Bitmap filepaths or do a search & replace on all (case insensitive)" width:906 height:495(
local arrBMs = #()
local arrPaths = #()
combobox cbx_bm "Bitmap Filepaths" pos:[6,5] width:890 height:31
button btn_get "Get Bitmaps in Scene" pos:[5,449] width:124 height:40
checkbutton ckb_edit "Enable Edit" pos:[134,449] width:140 height:40
edittext edt_s "Search for:" pos:[323,450] width:439 height:16 enabled:false
edittext edt_r "Replace with: " pos:[323,472] width:439 height:16 enabled:false
button btn_rep "Do for All" pos:[769,449] width:132 height:40 enabled:false
button btn_swap "Swap" pos:[279,449] width:40 height:40
fn update_list=
(
arrBMs = #()
arrPaths = #()
arrBMs = getClassInstances bitmapTexture
for i=1 to arrBMs.count do
append arrPaths arrBMs[i].filename
cbx_bm.items = arrPaths
)--end fn
on cbx_bm entered txt do(if ckb_edit.checked do(
arrBMs[cbx_bm.selection].filename = txt
update_list())--end if)--end on
on btn_get pressed do(
update_list())--end on
on ckb_edit changed state do(if state then
(
edt_s.enabled = true
edt_r.enabled = true
btn_rep.enabled = true)--end ifelse(
edt_s.enabled = false
edt_r.enabled = false
btn_rep.enabled = false)--end else)--end
on btn_swap pressed do(
temp = edt_s.text
edt_s.text = edt_r.text
edt_r.text = temp
)--end on
on btn_rep pressed do(
local searchFor = edt_s.text
local replaceWith = edt_r.text
if searchFor != "" AND replaceWith != "" then
(--loop through object names:for i=1 to arrBMs.count do(
local startIndex = findString arrBMs[i].fileName searchFor -- returns the starting index of the found stringif startindex != undefined do(-- replace the string at "startIndex" with length of "searchFor.count" with "replaceWith"
arrBMs[i].fileName = (replace arrBMs[i].fileName startIndex searchFor.count replaceWith))--end if)--end for
update_list())--end ifelse displayTempPrompt ">>>>>> Fill in what to search for and what to replace with! <<<<<<<"5000)--end on)
createDialog ro_bmRename
To see bitmap names, press the "Get.." Button. To edit them, enabled the checkbox. You can then select single bitmap filepaths in the list and change them on top. The changes will be accepted when you leave the edit field with your mouse.
You can also do a search and replace on all paths, e.t. to change "C:\" to "D:\"
or "silly.jpg" to "dummy.tif"
This is case insensitive, which might not be so good.
Be careful with it, better save to a new scene first before you accidently kill any paths.
Cheers
Hey, i use this script. and it really work for me. script change all jpg name according to me. but in max only. but its fine and i change name with advance rename. ALL OVER VERY GOOD SCRIPT. Save lots of time.
Comments
Corona Bitmap Support
Hi thats excatlu what Im
Hi thats excatlu what Im looking for but dosnt work.....it says
-- Syntax error: at bad, expected
-- In line: createDialog ro_bmRename[\c
Can I use it for 3dsmax 2016 and corona 1.5
thx for hrlp
Ill formatting of the post
Remove
[\code]
from the end of the code posted above.
Yes. It should a straight forward script there's little that can go wrong. Credit to the OP. I just made that edit for Corona.
okay , what he wants is...
actually what i want too...
is
the script to rename all bitmaps renamed to "scene name"+ extension.
i.e.
pine_tree.max has some mesh and two textures.
leaf.bmp
leaf2.bmp
he wants a script to do some actions so the result will become:
pine_tree.max
pine_tree.bmp
pine_tree2.bmp.
and materials target the new bitmap names...so they wont report as missing.
rename w/o relink, right?
I re-read 2-3 times the original question:
"I want to rename the textures, and the link of texture should be keep!"
and looks like all replies below are about Relinking texture #FileNames.--Here is 2 staffs:
And as you say
"the texture name is not correct"
, then give more details about.my recent MAXScripts RSS (archive here)
good subject, you want to turn an untidy scene into a tidy scene
like evermotion's scenes...
dont have a solution for you however...
mhm maybe tryout "Set Bitmap
mhm maybe tryout "Set Bitmap Parameters" here: http://www.oferz.com/maxscripts.php
It has an option to do a Search&Replace on bitmap filenames
Never get low & slow & out of ideas
I have try it,but the file
I have try it,but the file name is not change, how to set it?
Dont really know if this is
Dont really know if this is what you want but maybe it helps:
To see bitmap names, press the "Get.." Button. To edit them, enabled the checkbox. You can then select single bitmap filepaths in the list and change them on top. The changes will be accepted when you leave the edit field with your mouse.
You can also do a search and replace on all paths, e.t. to change "C:\" to "D:\"
or "silly.jpg" to "dummy.tif"
This is case insensitive, which might not be so good.
Be careful with it, better save to a new scene first before you accidently kill any paths.
Cheers
Never get low & slow & out of ideas
Nice Script
Hey, i use this script. and it really work for me. script change all jpg name according to me. but in max only. but its fine and i change name with advance rename. ALL OVER VERY GOOD SCRIPT. Save lots of time.
Ajs