ScriptSpot

Forum topic · Scripts Wanted

Update Bitmap paths for Multi Sub-object

By tuxmask75 · 2013-02-27

Description

What I'm wanting to do is clone an entire Multi Sub-object material.
And than use a max script to update all the paths for all the Bitmap textures within that multi material to a single path.

All this without disturbing the bitmap paths for the first multi sub-object material.

Comments (6)

Perfect !

tuxmask75 · 2013-02-27

Thanks a lot ! It really helps speed this project up so much !

try this

barigazy · 2013-02-27

fn arguments:
msoMtl --multiSubObject materia (in my case first material in ME)
u can use also object material, mtl Librari material etc.
filepath --set new file (bitmap) path like (@"c:\temp\mapsDir")
prxStr --this is optional (add prefix to new mtl name)
meSlot -- number of ME slot where you wan to create new multi material

fn copyMultiMat msoMtl filepath: prxStr: meSlot: = if isKindof msoMtl multiSubMaterial do
(
local newMtls = for m in msoMtl.materialList where m != undefined collect
(
mtl = copy m
mtl.name = if prxStr != unsupplied then m.name + prxStr else m.name
if (mapsArr = getclassinstances bitmaptex target:m).count != 0 do
(
for b in mapsArr where (getProperty b "filename") != "" do
(
newFilename = filepath + "\\" + (filenameFromPath (b.filename))
setProperty b "filename" newFilename
)
)
mtl
)
if meSlot <= 24 do (meditMaterials[meSlot] = multiSubMaterial materialList:newMtls ;
)
--example
copyMultiMat (meditMaterials[1]) filepath:(@"c:\temp\mapsDir") prxStr:"_copy" meSlot:2

Could not figure out how to operate the script,

tuxmask75 · 2013-02-27

Actually I just wanted to change directory for all the bitmaps alone in selected multi-material.
looks like this one makes a new material.

barigazy · 2013-02-27

You asked to make a clone material

repath multimaterial bitmaps

barigazy · 2013-02-27

This will change the filePath of selected multisub mtl

fn copyMultiMat msoMtl filepath: =
(
for m in msoMtl.materialList where m != undefined do
(
if (mapsArr = getclassinstances bitmaptex target:m).count != 0 do
(
for b in mapsArr where (getProperty b "filename") != "" do
(
newFilename = filepath + "\\" + (filenameFromPath (b.filename))
setProperty b "filename" newFilename
)
)
)
)
copyMultiMat (meditMaterials[1]) filepath:(@"c:\temp\mapsDir")

tuxmask75 · 2013-02-27

sorry, I should really be careful how I word my requests.