ScriptSpot

Forum topic · Scripts Wanted

Condense Same Named Materials to Master Instance Material

By AniMill · 2009-09-20

Description

If I'm missing this, I'm sorry. But My scenes have multiple objects using the same materials with the same names, but they each come into the MatEd as individual materials. This is a huge PITA when I need to change one material then propagate that change across multiple objects.

Can someone write a script that finds all materials with the same name, have the option to correlate the materials to ensure they are actually the same setup (or with in a few parameter close) then use a master material as the new instance material that replaces all other same-named materials.

Please contact me with your costs and time availability. This is a need-it-now item.

Thanks in advance,

Curtis Sponsler | AniMill

Comments (17)

Condense Material / Bitmap Condenser

rio ma · 2018-06-20

Hi Marco, I'm searching for a script that is similar to the condense material script,
I have a large file that has several duplicate bitmaps in the material editor and would like all the materials that use the duplicate bitmap to be merged/instanced. Is this something you could help me with? - Mario

hmm, such questions continued frequently

Anubis · 2011-07-14

fn InstanceMatByName mat = (
	(for o in objects where o.mat != undefined and o.mat.name == mat.name collect o).mat = mat
)

--example usage:
InstanceMatByName (meditMaterials[1])

willchocks · 2018-10-17

I know this is 7 years old, but i've tried this code and it does nothing :(. I'm using max 2016, is there any reason why it doesn't work?

I just get this returned in the listener:

InstanceMatByName()
01 - Default:Standard

stenionet · 2011-07-13

Marco Brunetta
When I press "Condense Materials" the dialog closes and nothing happens.

Kstudio · 2016-01-17

Also you can find script InstanceMatByName in TrackScripts pack.


Select material in Material Editor and run script InstanceMatByName.


All materials with same class and name will be convert to instance.

Marco Brunetta · 2009-09-21

Piece of cake! It now always select the first entry when creating the tree. How's that?

Attachments

AniMill · 2009-09-21

You are sick dude! ;-)

OK, so ya want a tough one? How about a silly little File Loading/Saving Progress Indicator?

I can't stand that all MAX says when you are saving files is: "Saving..."! I've got big-ass files I'm saving and I have no idea how long to wait before I can click on the screen (or take a bathroom break).

If there was a way to make a UI Dialog Box with an accurate saved Mbyte -vs- total Mbytes and estimated time progress bar - that'd be fab! Even better, would there be a way to modify the standard interface in the lower-left corner to replace or add-to the "Saving..." message.

This one I bet you could sell!

I still want to get you something for your help - seriously, NewEgg, Amazon, Apple giftcard?

Marco Brunetta · 2009-09-22

That actually IS a tough one. Even tough I can call the save function from maxscript, I don't have any control over what it does or have any feedback. And since the max format is not opensource I can't neither reproduce it. So I'm gonna pass on that one, sorry.

Well... if you'r feeling generous, there's always my PayPal account at mbrunetta@gmail.com . All donations go towards getting more beer on weekends. =D

Take care.

AniMill · 2009-09-22

I do insist! Beer's to you!

No worries on the "Save" thing. I'll just keep hammering Autodesk on that one.

Doesn't work :(

willchocks · 2018-10-17

I know this is almost 10 years old, but this script doesn't do anything when i try to run it in 3ds max 2016 :( Is there any way to modify it to make it work?

Thanks

I just get this in my listener:


Rollout:condenseMats
true

AniMill · 2009-09-21

OK, I have one suggestion: Have a "Select First" button where it automatically selects the first check-box in each multi-copy material. Just a short-cut to speed things along.

Thanks again.

cas

AniMill · 2009-09-21

Bowing down low before you... you ever need some After Effects composites or MAX production, don't hesitate to email me: c.a.sponsler[at]animill.com

Thanks!

Marco Brunetta · 2009-09-21

Haha, yeah I tend to make a lot of those =P

Don't worry about it mate, like I said, I had bits and pieces of it around my HD, I just had to tie them up together.

Enjoy!

Marco Brunetta · 2009-09-21

Cool, let me know how it goes.

M.

AniMill · 2009-09-21

How much do I owe you?! It just saved me tons of time of tedious work... MUCH appreciated.

(p.s. the first line has a misspelling: "rollout condenseMats "Condese Materials" width:275" Should be "Condense" - damned typos!

:-)

Marco Brunetta · 2009-09-21

I had worked on something along these lines some time ago, so I just fixed it up a bit for you. Have a look at the attached script.

When you run it, it will list all of the materials in the scene by name on a treeView. If two are more materials have the same name they will be displayed as separate subNodes of the main material node. You can use the checkboxes to choose which one of the materials will be the "master", in other words, which material will replace the others with the same name. Disabling the checkbox at the top nodes will keep the script fro doing any changes to the materials with that name.

You can double click any of the subnodes to select every object in the scene using that material, this should help you to find which one to use as a master.

It was packed together pretty quickly, so there might be some bugs in there but give it a go and let me know.

Good luck.

Attachments

AniMill · 2009-09-21

Marco - I'm rebooting my workstation then I'll give this a test. Thanks!