Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Reload material library with maxscript

Reload material library with maxscript

chroma123
Advocate Advocate
2,700 Views
8 Replies
Message 1 of 9

Reload material library with maxscript

chroma123
Advocate
Advocate

In our studio, we have a set of material libraries that we use in common. When someone makes any change within any of the libraries, the other people need to reload the library manually, or avoid pressing save library when closing their file (which is harder than it seems when you're about to save your scene to exit max) One mistake, and the changes someone made is gone.

 

It would be best to have material libraries being updated automatically, but since I guess that's impossible from what I can find in the settings (Unbelievable, isn't it!?), I'm looking for a way to make a button everyone in our studio that can use to easily update a given library, or even the entire loaded material library set. Any maxscript help for achieving that would be very much appreciated!

0 Likes
2,701 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable

I'm looking for the same thing 🙂

Message 3 of 9

chroma123
Advocate
Advocate

Hmm... Any people around with some ideas? 

0 Likes
Message 4 of 9

Anonymous
Not applicable

I dont generally put links to scripts as I like to write code, but I am on my way home so have a look at the link and see if it helps. You can look in the .ms file for maxscript that may help.

 

http://www.scriptspot.com/3ds-max/scripts/load-material-library-from-path

 

regards

0 Likes
Message 5 of 9

chroma123
Advocate
Advocate

Thanks. I've took a look at this script, but it doesn't reload libraries, only loads the ones from a given directory that's not already loaded, and it loads as a temporary library.

 

Looking at this page https://help.autodesk.com/view/3DSMAX/2016/ENU/?guid=__files_GUID_D10CEFAB_E451_4A63_968E_01AEDEFCE9... and neighter getting any wiser regarding reloading here.

 

Ultimately, it should be as easy as 

on btn_updateLib pressed do (
      reloadMaterialLibrary "f:\path\to\file.mat"
)

 

But a workaround seems to be a lot more complicated. 

0 Likes
Message 6 of 9

Anonymous
Not applicable

Well, if you know the url of the .mat library, why will this not work?

mat_path = "path\to\material.mat"

on loadMat pressed do
(
loadMaterialLibrary mat_path
)

You could update your bitmap paths or have a ui that collates from a specified directory into a list. Then a user can select from the list and hit the button.

 

Would that work for your requirement?

 

Maxscript or python based? 

 

Im on the move at the moment, so just posting ideas etc. Can filter later

0 Likes
Message 7 of 9

chroma123
Advocate
Advocate

Thanks for replying. 

 

That works in some way, but just in sense that if library is already loaded, it doesn't reload it, and if itsn't loaded, it creates a temporary material library.

 

The main idea for me is having a sync tool for material libraries. 

If someone in our studio updates a material in one of our libraries (mind all of these libraries are loaded in everyones max), saving the library, and one of the others are closing down max, they get the question to save the library or not. If that person hits "save", then all changes will be lost, and the library is reverted to this persons library state. 


The best would be letting the libraries automatically reload in everyones max when someone saves it. Why isn't this a thing? Since, as least as I am aware of, there's not function that covers this (?), a maxscript button with reloading the library would be decent enough. Of course we have to notify the rest of the studio on mail or something about a material change, and everyone have to manually click a button to reload that library in their max, to avoid the potential "save library" issue when someone else is closing max.

 

With continuously optimizing our materials, this is a certain issue for us.

0 Likes
Message 8 of 9

Anonymous
Not applicable

Tried a callback? That may prove useful

 

For our studio, we have a database of materials (sql), bitmaps, versions etc and also a publishing tool for materials. When a new material is created (.mat), its registered in the database and any artist calling on that material does so through a custom browser with the newest being the default and a history of previous versions for older projects.

 

Sounds like what you want, but I am unable to post the code due to NDA. If I get chance, I will see what is inside and post some snippets. Its been a while since I wrote it, so will have to refamiliarise myself with it.

 

regards

0 Likes
Message 9 of 9

chroma123
Advocate
Advocate

Thanks for the idea. It sounds a little too complicated for my knowledge. Smiley Very Happy I think it should be possible to solve this in a more cost effective way. Publishing the materials to a database do sound very nice, but still not very compatible without spending money on future releases of max and vray.

 

Like, ultimately, closing the material library and then loading it again when pushing a button would be sufficient.
Creating a callback for this to happen, yeah that might be something as well, but it has to be written as a plugin to max, I believe?

0 Likes