Multiple objects materials into single multi/sub object material

Hi everyone, I'm trying to apply one single multi/sub object material to control different objects. Each object has it's own material created so what I want to do is get those materials and join them into a single multi/sub object material that I can apply to all the objects. Can anybody help me with a script than can make that? Thanks!!

Comments

Comment viewing options

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

ID error

Hey there. I tried out the script. Works for object counts till "11", but after the 11 object, the mmtl adds only the ID 11 for any further material. So the you get the dublicate material ID error message. The matID modifier is getting the right count up after 11.
I think there is missing a command line that the mmtl knows how to count after 11 :D Anyone knows what is missing?

//EDIT: tried .materialList[i] and .materialIDList[i]. No success. meditMaterials[1].mapEnabled[100] works. But I would have to set a endless list manually.

panducho's picture

Cool!!!

Thank you very much for your help!!!! Awesome!

panducho's picture

Thank you barigazy, this

Thank you barigazy, this solves the main part of my problem, it collects all materials into one single multi/sub object!! now, how can I assign the correct ID to all the objects in order to match the ID of the multi/sub object material created?

barigazy's picture

...

You can do that by using Material modifier

if selection.count != 0 do 
(
	mmtl = multimaterial name:"SelectionMtls" 
	mmtl.materialList = for i = 1 to selection.count where selection[i].material != undefined collect
	(
		addModifier selection[i] (Materialmodifier materialID:i)
		selection[i].material
	)
	selection.material = meditMaterials[1] = mmtl
)

bga

barigazy's picture

...

try this

mmtl = if selection.count != 0 do 
(
	multimaterial name:"SelectionMtls" materialList:(for o in selection where o.material != undefined collect o.material)
)
--add new material to material editor (first slot)
meditMaterials[1] = mmtl

bga

Comment viewing options

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