Select Objects by Multiple Materials?

I used ninjaripper to rip a map from a game, what it does is that I have to rip certain times and it creates many duplicated materials with the same name.
I would like to request a script that I can select objects by multiple materials so that I can apply one material on the objects I selected

for example:
http://img203.imageshack.us/img203/1772/20229927.png

Please help me! I have about 3500 textures and I can't really select one by one and merge the textures......I appreciated it a lot!!!

Comments

Comment viewing options

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

Topic changed

http://www.scriptspot.com/forums/3ds-max/scripts-wanted/condense-by-bitm...

This topic is outdated, check the topic above

Anubis's picture

mission impossible perhaps...

After reading your last reply:

but some different textures have the same name but in different directory, if I put them all in the same folder some texture will be replaced!

I wonder how anyone can resolve this with script then, because how the code would know which textures are different?

Well, there is CompareBitmaps() function but... not really safety way.

However, as you open new topic, then post your last notes there too for a better chance to get good help ;-)

my recent MAXScripts RSS (archive here)

barigazy's picture

:)

From the very beginning I assumed that they would be "mission impossible" with Tom Cruise

bga

barigazy's picture

try this one

With this little tool you can select objects by material name or material active slot (from the Material Editor)

try(destroyDialog ::bgaRoll)catch()
rollout bgaRoll "SelectObjByMtl"
(
	checkbox lbl "Material Name:" pos:[5,2] width:150 checked:true
	edittext mtlname "" pos:[0,20] width:195 height:17 enabled:(lbl.checked)
	spinner mtlslot "Material Slot:             " pos:[4,40] enabled:(not lbl.checked) type:#integer range:[1,24,1]
	button selobj "Select Objects" pos:[5,58] width:190
 
	on lbl changed state do (mtlname.enabled = state ; mtlslot.enabled = not state)
 
	on selobj pressed do
	(
		local mtlObj = #()
		for obj in objects where obj.material != undefined do
		(
			if lbl.checked and mtlname.text != "" do (if obj.material.name == mtlname.text do append mtlObj obj)
			if not lbl.checked do (if obj.material == meditMaterials[mtlslot.value] do append mtlObj obj)
		)
		if mtlObj.count == 0 then (messageBox "This Material is not assigned to any object" title:"Warning" beep:off) 
		else (select mtlObj ; free mtlObj)		
	)
 
)
createDialog bgaRoll 200 80 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

bga

brianuuu's picture

it seems like it select all

it seems like it select all objects that have the material named Tex_0030_0.dds, is it possible to list all the materials in the order like from "Get from Material" list and let me select part of the materials and then select the objects with the materials I selected?

barigazy's picture

All the material share same

All the material share same name. That is the problem. It's better to select all objests that use same bitmap in diffuse map slot.
Now the question is: Are these maps instances?

bga

brianuuu's picture

I think they are all

I think they are all instances, btw the material name is actually the texture name, but with different directory

barigazy's picture

solution #2

Select a object with one of these mtl and press the button

rollout test "SelectByBmp"
(
	button sel "select objects"
	on sel pressed do
	(
		if isValidNode selection[1] and selection[1].material != undefined do
		(
			if (objMap = selection[1].material.diffuseMap) != undefined do 
			(
				select (refs.dependentNodes objMap)
			)
		)
	)
)
createdialog test

bga

brianuuu's picture

maybe this picture will

maybe this picture will explain more

http://img341.imageshack.us/img341/5658/80226988.png

Red Box are the materials with the same texture but with different directory
like: C:\Frame0000\Tex_0030_0.dds and C:\Frame0001\Tex_0030_0.dds

Red Box and Blue Box shares the same material name but have different textures with unique directory.

So simply all textures there have the unique directory, I guess it would be better to have a list like Material/Map Browser and slot them in the order like in the browser, then for example if I select the materials in the Red Box, it will select mesh 1921, mesh1950, mesh2009, mesh 2031 and mesh 2060. I think the list has text only will be okay, cuz I can check the number of materials I have to select in the Material/Map Browser.

Or, if you could slot the geometry names in "Select by names" like int the Material/Map Browser, its fine too, then I can select the geometry I need faster.

Anubis's picture

Hi Brian

I think that you s'd first move all *.dds to one folder, e.g. C:\Frames and then in Max -
step #1: relink texture maps;
step #2: condense scene materials;

dest = "C:\\Frames\\"
 
-- relink .filename of bitmapTexture's
allBMs = getClassInstances bitmapTexture target:sceneMaterials
for map in allBMs where map.filename != "" do
map.filename = dest + filenameFromPath map.filename
 
-- then 'condense' standardMaterial's
allSMs = getClassInstances standardMaterial target:sceneMaterials
index = 0
DO (
	index += 1; mfn = allSMs[index].maps[1]
	for i = (index+1) to allSMs.count where allSMs[i].maps[1] == mfn do
		replaceInstances allSMs[i].maps[1] mfn
	allSMs = getClassInstances standardMaterial target:sceneMaterials
) While index < allSMs.count

my recent MAXScripts RSS (archive here)

Comment viewing options

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