rename multi/sub materials

hi there,

in a current project I am working on I am using a large multi/sub material. All sub materials are named 'standardmaterial' and have a different bitmap assigned to their diffuse channel.
Now I'm trying to rename all the materials according to their bitmap name, so the 'standardmaterial' needs to be replace by 'bitmapname'. Because the multi/sub material has more than 400 materials, it's obvious this needs to be automated.

is their any way I could call upon the diffuse channel bitmap name of the material and output that as the sub/material name by means of scripting? You should know that my scripting skills are poor and in a starting phase...

thanx in advance,

Harmalarm

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anton Berg's picture

I have attached the basic

I have attached the basic code for doing this. I haven´t done any userinterface but just OPEN this script and try it out.

I works on the currently selected material in the material editor.

--------- the code snippet

--get the current selected material
--in the material editor slot
yourmaterial = medit.GetCurMtl()

numberOfSubMats = yourmaterial.numsubs
--how many submaterials exist in the selected material

for i = 1 to numberOfSubmats do
(
try
(
bitmapName = getFilenameFile yourmaterial[i].diffusemap.filename
yourmaterial[i].name = bitmapName
yourmaterial.names[i] =bitmapName
)
catch (
print ("could not set name for this material" + yourmaterial[i].name)
)
)
---------end code snippet

AttachmentSize
OS3D_SetMaterialName_v01.ms 566 bytes

OgmaSoul3D
Anton Berg
anton[at]os3d.se

Harmalarm's picture

:O I am overwhelmed by the

:O

I am overwhelmed by the fast response! It works exactly the way it should!

Anton, you saved me a lot of time. Thank you VERY much!

Harm Sollie

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.