Update Bitmap paths for Multi Sub-object

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

Comment viewing options

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

Perfect !

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

barigazy's picture

try this

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

bga

tuxmask75's picture

Could not figure out how to operate the script,

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's picture

You asked to make a clone

You asked to make a clone material

bga

tuxmask75's picture

sorry, I should really be

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

barigazy's picture

repath multimaterial bitmaps

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")

bga

Comment viewing options

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