Notifications
Clear all

[Closed] exporting a multisub material with each sub material and maps used???

hi

i am trying to create a script (my first script) that exports a multisub material by name and the name of the map + type of map it uses into a text file

any heads up or ideas…

5 Replies

This is kinda werid, I just wrote a script (last night) that does something very simular…


 if (classof $.material) == MultiSubMaterial then (
 	-- List all the sub material elements
 	for material in $.material.materialList do (
 		/*
 			Here's the tricky bit...each sub material can be a different material type, for now,
 			I'm only going to filter standard materials
 		*/
 		if (classof material) == StandardMaterial then (
 			-- Print the name of the material
 			format "Material name = %
" material.name
 			
 			-- Process all the different maps of the standard material
 			for map in material.maps do (
 				-- For this exercise, I'm only looking for BitMapTextures
 				if (map != undefined) and ((classof map) == BitmapTexture) then (
 					format " - Map = %; %
" map.name map.filename
 				)
 			)
 		)
 	)
 )
 

This is restrivtive method, I look for very particular texture and material types, but it should give an idea of how to proceed.

If you want to, you could write a number of common functions that deal with common texture types, such as filtering Standard material, then filter BitmapTexture, so that you can call them from different locations within in your code, rather then duplicating it

Cheers
Shane

thanks shane… ur script will definitely help i am sure…

will post how it goes…

if i go through each sub material in multi sub i can find out the name and maps used but how to find out the type of map it is being used as…??? i only want to print the type (diffuse, specular etc) of maps and map file names

Try this:


fn PrintChannelFileNames multiSubMaterial =
(
	if(classOf multiSubMaterial == Multimaterial) then
	(
		for m in 1 to multiSubMaterial.materialList.count do 
		(
			for t in 1 to multiSubMaterial[m].maps.count do
			(
				ss = stringStream ""
				
				format "Material:% " multiSubMaterial[m].name to:ss
				format "Map:%:" ((getSubTexmapSlotName multiSubMaterial[m] t) as string) to:ss
	
				mapTest = getSubTexMap multiSubMaterial[m] t
				
				if(mapTest != undefined) and (classOf mapTest == Bitmaptexture) then
				(
					format "%" mapTest.filename to:ss
				)	
				else
				(
					format "%" "n/a" to:ss
				)
				
				seek ss 0
				
				print (ss as string)
			)
		)
	)
	else
	(
		return false
	)
)

Using the two material methods:

getSubTexmapSlotName
getSubTexMap

You should be able to get what you want. Obviously, this code is just for reference, but you can manipulate it to get whatever you want.

Hope this helps.

-Dave

thanks dave… was looking at each map type and checking if its enabled or not. now with your code i can optimize my script. thanks a lot