Updating scene materials from library

hello everybody

I need a script which updates my scene materials from a library as pre-render script.
I do not knowing anything about scripting, so you pro's are my last chance. :)

your help is much appreciated and would save me a lot time. I have about 40 scenes to update.

thanks for your effort.

best regards
themaxxer

Comments

Comment viewing options

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

THANK YOU VERY MUCH

THANK YOU VERY MUCH anubis!!!
you've saved me a lot of time.
great, I love scripting, but I can't do anything myself. :)

have a nice time, guys, and thanks.

best regards
themaxxer

Anubis's picture

Update Scene Materials

I think i see what you need. The bad news is that no bulit-in function for quick updating scene mat's. The good news is that i have something for you:
http://project3d.narod.ru/mxs/UpdateSceneMaterials.rar

A time ago i wrote a quick fix for Max 2011 issue with Compact Material Editor where Put Material To Scene was disabled. Soon after that SP1 was out and this was fixed, but the script is still useful for automation.

It's a macro script and put all mat's form the current mat-lib to the scene OR if you hold Shift key while invoke the macros will put only the Active ME material to the scene.

If you still prefer to update your mat's using pre-render script, try this (*note - not tested):

matLib = loadMaterialLibrary "X:\\store\\dummy.mat"
for mat in matLib do (
	insMats = getClassInstances (classOf mat) target:sceneMaterials
	for ref in insMats where ref.name == mat.name do replaceInstances ref mat
)

my recent MAXScripts RSS (archive here)

br0t's picture

haha 4 lines of code :D omg,

haha 4 lines of code :D omg, is this yoda talking to me?

Never get low & slow & out of ideas

Anubis's picture

:)

haha, nice :)

my recent MAXScripts RSS (archive here)

themaxxer's picture

thanks br0t it's a great

thanks br0t

it's a great script, but I ask myself if there's no easier way to load and update the materials.

something like: loadmateriallibrary "X:\\Dummy\\Custom Maps\\dummy.mat"
and then the command for updating?
I don't know how, but I have the idea! :)

I am working with max 2010 and the update scene materials works as excepted.

thanks for helping.

bets regards
themaxxer

br0t's picture

Hey, I think I may help you.

Hey,
I think I may help you. Ive run into a similar problem in a project and wrote a script to handle it. Its called "sceneMats_IO" and you find it on my website. You need to have one max file ("master scene" if you want so) containing all your objects with correct materials applied. The script can save those material into a library file, as well as a text file containing object-material relations.

If you then have your other 40 max files, and the objects do have the same names as in your master file (important!), you can just hit the "import" button and the materials will be updated. It is not written as a pre-render script but may be helpful anyway, even if you have to use it 40 times.

This is all based on simply comparing object names and applying materials from the library based on that. So if you have 100 objects that are all called "Box" you will run into problems (the script will not fail, but some objects will not be textured), all objects should have a unique name.

Cheers

Never get low & slow & out of ideas

Comment viewing options

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