rename bitmap character number
well, another script request by me,
for my project I also need to reduce the number of characters from each bitmap. With the actual bitmaps on the hard drive, this is no problem.
But within 3ds-Max the bitmapName also needs reduction to 16 characters.
I tried this, based on anton berg's earlier script and an object rename script I found on the net;
----------------
--yourmaterial = $.material -- get the material you want to work on from the selected object
yourmaterial = medit.GetCurMtl() --get the current selected material in the material editor slot
numberOfSubMats = yourmaterial.numsubs --how many submaterials exist in the selected material
for i = 1 to numberOfSubmats do
(
try
(
startVal = 1
endVal = 16
bitmapName = getFilenameFile yourmaterial[i].diffusemap.filename
yourmaterial[i].diffusemap.filename = replace bitmapName ((endVal-startVal)+1) ""
)
catch (
print ("could not set name for this bitmap" + yourmaterial[i].diffusemap.filename)
)
)
-----------------
doesn't work however. Can someone tell me what the problem could be?
Maybe I'm totally off here, but at least i should be able to do something with the number of characters, as a list or a string or something?
Harmalarm
Comments
well, I got it working on my
well, I got it working on my own, fiddling with the maxscript reference.
It is rather slow though, and it currently strips the paths of the textures. this is not really a problem thought, but maybe it can be improved in speed? (I for one wouldn't know how, but it works anyway) by the way, it turned out I was in need of 15 character textures, not 16... therefore the 15 in the script
it's based on Anton Berg's earlier script. what do you think of it?
yourmaterial = medit.GetCurMtl() --get the current selected material in the material editor slot
numberOfSubMats = yourmaterial.numsubs --how many submaterials exist in the selected material
for i = 1 to numberOfSubmats do
(
try
(
n=getFilenameFile yourmaterial[i].diffusemap.filename
nn=substring n 1 15
append nn ".tga"
yourmaterial[i].diffusemap.filename=nn
)
catch (
print ("could not set name for this bitmap" + yourmaterial[i].diffusemap.filename)
)
)
with help of the other script, this is actually my first script ever! :)