ScriptSpot

Forum topic · General Scripting

DETECT MAT ID FOR THE TEXTURES INSIDE MULTISUBOBJECT MATERIAL

By artrender.info · 2013-02-12

Description

And how can I find out the IDs for all the textures in a certain multisubobject material (not especial for a certain object to find IDs from faces but inside material)

Comments (6)

or...

Anubis · 2013-02-13

mat = meditMaterials[activeMeditSlot]
if classof mat != multimaterial then
	messageBox "Select a MultiMaterial!"
else
(
	mIDList = mat.materialIDList
	
	format "Sub-materials (ID | Material):\n"
	for m in mIDList do
	format "\t% | %\n" i mIDList[i]
	
	txtList = for i in mIDList collect \
	#(i, getClassInstances bitmaptex target:mIDList[i])
	
	for itm in txtList do
	format "Textures under mat with ID: %\n\t%" itm[1] itm[2]
)

PerfectCell · 2013-02-13

For my sake, can you explain why you modified my code the way you did? I'm still learning and have no idea about Maxscript best practices.

Hi PerfectCell

Anubis · 2013-02-14

Why you think I modify your code?

Your code only display mat id's in listBox, but not the textures under them (what is the actual user question).

Also for simplify sake my code has no ui rollout.

PerfectCell · 2013-02-14

Oh ok. I understood his question differently.

I made a rollout so he could simply dump the code into his scene and have an instant visual result to see what's going on and play with it from there.

Thanks for the reply.

PerfectCell · 2013-02-13

See what you can get out of this ;)

rollout subIDTest "Untitled" width:211 height:176
(
	button btn "Button" pos:[58,134] width:89 height:32
	listBox idList "ListBox" pos:[20,7] width:165 height:7
	
	local id = #()
	local derp = #()
	
	on btn pressed do
	(
		mat = meditMaterials[activemeditslot]

		if classof mat == multimaterial then
		(
			id = mat.materialIDlist
			
			for i in 1 to id.count do
			(
				append derp (id[i] as string)
				idList.items = derp
			)
		)
		else
		(
			messagebox "Select a multimaterial!"
		)
	)
)
createdialog subIDTest