tidying up a scene with 1000's of nearly identical materials.

ive got an fbx of a satellite that has been converted from who knows what. not only is it 18000 objects (in some parts each poly is an object) but it also appears to have 18000 (non vray, sometimes cryptically named) materials to go along with it.

i initially assumed that the names were consistent (i.e. 1000 materials all named “brushed steel” ) in which case a script like “instance materials by name” from the kstudios pack would have resolved it fairly easily.

however on seeing the full list of materials i see i have, for example:

brushed steel -32 copies
brushed steel#1 -43 copies
brushed steel_base -97 copies
brushed steel_base #54 -12 copies

etc etc.

so in the end even if i condense all the identical ones, ill *still* have several hundred+ materials, and the kstudios one only works for IDENTICAL names.

what i want is a script that allows me to choose a chunk of materials from a list (even with varying names) and instanciate them all to a single material.

any suggestions? client is (of course) expecting that ill just be able to grab this model and use it. if i have to spend a week cleaning it up itll be an issue.

As a quick fix maybe do this:

Identify how many materials there are, disregarding copies.
E.g. if there are 5 materials then create 5 objects and assign each one of the 5 mats. Save selected objects and delete/remerge them, which will give the opportunity to overwrite those existing 5 mats, which
should then be the only materials in the scene.

that works for identically named materials.. as noted ive already got a script to instanciate those. my problem is the hundreds (possibly more than a thousand) *similarly* named materials i.e. brushedmetal 1, brushedmetal 2, brushedmetal_panels, brushed_metal etc etc.

Ah ok, I see. Nothing’s ever simple with dumb imports :frowning:

Hopefully there’s a scriptable method to sort it out.

no the scene is a real mess, 4600 max objects, a heirarchy based on linked helpers at least 20 branches deep, with everything named semi-randomly, half an object (random faces) in one max object, 3 faces in another, and the rest in a third. god knows where it was exported from, almost looks deliberate. all i can say is the source is a multibillion dollar space technology company so youd think they would have some good workflows.

I don’t use built in Max importer due to reasons described above.

I use Polytrans importer instead. The resulting scene is better organized but still contains proper hierarchy.

This sounds easily scriptable actually, you can try ChatGPT for that. I wrote a bunch of scripts together with ChatGPT or Claude.ai to clean up things like this. I’d say give it a try.

yeah i tried chatgtp, copilot and claude.ai (all free versions) not one of them could produce a working script, and all had a habit of going round in circles with their modifications when shown the error messages.. not impressed.

Yeah the free versions aren’t good enough for that most of the time, also it helps if you have a bit of coding experience prior ofcourse.

Is it possible to do this based on geometry itself. I normally use search word based on *object name* and this way make selection sets. Another option would be to select objects based on face amount. If there are unwanted objects selected as well just unselect those.

This is my way for organizing scenes containing hundreds of thousands of objects.

in the end this script sorted the scene enough to start going through the geometry and tidying up:

it reduced the scene from 4000+ materials to 12.. took a while to process but does not appear to have broken anything. client also finally sent through some (bad) reference photos, so i have something to work from. thanks all.

That’s a lucky find! Glad you got a solution as the thought of manually doing this was anxiety-inducing lol :stuck_out_tongue:

Do you still need help?
Lele wrote a script that condenses materials, I still use it from time to time