Smart material merger/renamer

Hi, guys, I was wondering if any of you script-wizards can help me out. We need to have a script that imports models in a specific way:

When importing 3ds MAX scene into another and when prompted for duplicate materials, we need the script to check if ALL of the parameters of the material in question are the same as the duplicate. If yes – merge/use scene materials, if not – auto rename.


Imagine a very large scene with millions of polygons, and hundreds of different materials and everything is ok for the moment. Now, I need to update that scene (numerous times) to accommodate for client’s wishes. I will have to distribute various parts of the scene to 10 different modelers for an update and then, once everyone’s job is done, bring them all back to one giant scene.

In order to keep the original materials in the final scene (to not accidentally overwrite them), everyone has to follow a very strict instruction on how to add new materials to his extracted small scene and how to modify existing materials – that is to always make a NEW NAME for the material, so that we can USE SCENE MATERIALS (when prompted for duplicates) when merging the whole thing back in the giant scene. The goal is to not use the AUTO RENAME DUPLICATE MATERIALS option, because of the loss of connection between materials that are the same in both scenes, those that were not modified. This is the imperative.

Problem is, sometimes, one or more modelers makes an unconscious mistake on his specific part of assignment - he changes a couple of material parameters on one or more materials in the scene AND keeps the SAME NAME of the material in question. This in turn makes a problem when we import his model in the giant file – his new or modified materials are overwritten by our old materials in the giant scene, since we used USE SCENE MATERIALS option (when prompted for duplicates).

This occurs more often than not and we are trying to find a workaround for this problem. This script would enable us to bypass human error and thus enhance our workflow. Name your price and time constrictions.

Thank you for your time.


Comment viewing options

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

Thank you for your response

Thank you for your response fajar.

I am afraid that my script skills are very limited. What I have understood is that this (part of the) code you mentioned is 3ds MAX’s native way of handling duplicate materials when importing external files. Doing a follow-up on your suggestion is not within my expertise, I am afraid that I would require help in this regard.

What I do know is that the crucial part of the problem is where MAX has to cross-reference material parameters one-by-one and then come to a conclusion on whether or not the criteria is met for merge/use scene material or auto-rename.

Is this is feasible and how?

fajar's picture

see maxscript documentation

see maxscript documentation see mergemaxfile section....
I wonder if its merging or import [note theres different merge n import]

mergeMAXFile <filename_string> [<name_array>] [#prompt] \
[ [ #select ] #noRedraw ] \
[ #deleteOldDups | #mergeDups | #skipDups | #promptDups ] \
[ #promptMtlDups | #useMergedMtlDups | #useSceneMtlDups | #renameMtlDups ]\
[ #promptReparent | #alwaysReparent | #neverReparent ] \
[ quiet:<bool> ] \
missingExtFilesAction: <actions> missingExtFilesList: <&variable> \
missingXRefsAction: <actions> missingXRefsList: <&variable>

if its merge maxfile...

see part [b][ #promptMtlDups | #useMergedMtlDups | #useSceneMtlDups | #renameMtlDups ][/b]

ex :

mergeMAXFile "D:\\maxfile\\001.max" #renameMtlDups #select quiet:true

Comment viewing options

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