Maxscript: Condense materials with same name

It does work for the macroscript part etc, but it still is much slower when the material/map browser is opened. Which is no problem, as long as you think to close it before running the script. Anyway, this saved tons of my time already. Dreary stuff, these duplicate materials…

Browser open

Browser closed

Oh, you use slate?
Material Explorer?
Standard material browser?
The material editor (i.e. the old max one) and any child windows should get closed by the script (i couldn’t imagine why it would not.).
I could, with some difficulty, also manage slate.
I can’t touch those other two windows from maxscript (i know of no obvious way to do so, yet.).

Alas, yes, it’d be wise to not have max refresh the material list each time a material is condensed (which happens MANY times.), so close any browser window with the material list in view.

First thing I do on a fresh install: Switch to old material editor and old style material browser. The new one is even slower.

I found working with slate *very* frustrating, both as max user, and as scripter.
The new “asset browser” windows and such seem cool, but i fear their handling may be quite problematic (i.e.: so far they seem to lack the maxscript functions to open, close, and so on.).
I’m also quite ignorant of those two (the separate material browser, and the material explorer, i think new in 2020), so i’ll have to dig into them and see what’s what.
Thanks for providing me with the doubt! :smile:

I have to admit I am still on Max 2017, because every release after that had the annoying double-click bug in the render settings window.

Alright, there is a new bugger in a scene of data given to me.
The materials are the same, but they are NUMBERED for every single part. So, in the scene you have as many unique materials as there are objects. They are not really unique, though because it’s all the same material, only numbered. I hope the attached screenshots makes it clearer. How would I go about that?

I assume it would have to be done through hashing, again, minus the name check.
I added a second button to the new script version to do that.
Note that the script does not pick one specific material name to condense the rest to.
The first collected and with a matching hash will replace the rest.

Consider the new script mode very much beta, as i have no real scene, i can’t quite test it properly, and synthetic testing only goes so far.
You’ve been warned. :wink:

I just tried out the version, and I see the new button etc. But pressing it gives me statistics that it did nothing. Can I send over a test scene for ya?

please !

That’s fixed recently.
Old max version will get fixied when vray is ported over to Qt.

necroing this: the script v004 had a nasty little bug, and so one mode was broken.

So it moved to v005, and found another corner case to fix.
and now it moved to v006, and is also several times quicker with the same-name mode, the bigger the scene, the bigger the gains.

mergeMaterialsWithSameName_006.rar (2.5 KB)

Thanks go to @kosso_olli for finding the issues out.

Thanks again, works like a charm.
Much quicker, indeed! :+1: