Notifications
Clear all

[Closed] material import script – sample slot

is it possible to writte a script where you could import a material .mat file direct into the sample slot? without creating a material library.

sometimes we have 20-50 .mat files inside the folder. it would take a lot of time and clicks to open the material library and than import the material inside the slate material.
it would be a lot of faster if we could import the material inside the material sample slots window.

would it even be possible to have a script for 3ds max that does this?

27 Replies
4 Replies
(@denist)
Joined: 11 months ago

Posts: 0

how many materials are in there average mat library? what type of material are they? in short… why the loading is slow?

(@ice-boy)
Joined: 11 months ago

Posts: 0

vraymaterials.de.

colleagues from my team sometimes download from vraymaterials.de. and then i need to look through the materials and change the settings to fit our workflow. so i have sometimes 50 .mat files that i need to go through. there is only one vraymaterial inside.

(@denist)
Joined: 11 months ago

Posts: 0

it seems like your problem is a your current pipeline. the opening a mat file itself is not a time issue. the issue is to constantly repeat some and some again operations:

open browser

pick a file

load a file

change a property(ies)

open brower

pick a file

save…

so you need custom tool which will help you simplify these routine steps.

(@ice-boy)
Joined: 11 months ago

Posts: 0

my problem with max is that if i would like to test 50 materials i need to have 50 matlib opened. and than i need to delete them since i dont need them. haha

so if it would be possible with a script import the materials into the material samples sloth we wouldnt have the matlib opened and everything would be faster.

This fn alow you to load maximum 24 materials from any *.mat file to Material Editor

fn loadMatsFromLibToME libFile =
 (
 	if doesFileExist libFile do
 	(
 		local mLib = loadTempMaterialLibrary libFile
 		for i = 1 to mLib.count while i<25 do meditMaterials[i] = mLib[i]
		mLib = undefined ; ok
 	)
 )
 --example (change filename)
 loadMatsFromLib @"C:	emp\mymaterials.mat"

With this function you can load all materials from all *.mat files placed in some directory, to SME.
This will create new view in SME named as *.mat file name.
NOTE: Be sure that all *.mat files is copatibile with your max version

fn putMatsFromLibToSME matFolder =
 (
 	if doesDirectoryExist matFolder do 
 	(
 		local matFiles = getFiles (pathConfig.appendPath matFolder "*.mat")
 		if matFiles.count == 0 then (messageBox "This Folder Not Contains Any *.mat File!" title:"Warning" beep:off) else
 		(
 			if sme.IsOpen() do sme.Close()
 			for i = 1 to matFiles.count do
 			(
 				view = if i == 1 then (v = sme.GetView (sme.activeView) ; v.name = getFilenameFile matFiles[i] ; v) 
 				else (sme.GetView (sme.CreateView (getFilenameFile matFiles[i])))
 				mLib = loadTempMaterialLibrary matFiles[i]
 				for m = 1 to mLib.count do view.CreateNode mLib[m] [(m-1)*300,0]
 			)
 		)
 	)
 )
 --example (change path to your directory)
 putMatsFromLibToSME @"c:	emp\myLibDir"

This is another example (SME related) that I posted a long time ago on scriptspot

thanks. with the first two scripts i get an error. type error. call needs function or class. got undefined.

did i type the wrong path?

3 Replies
(@gazybara)
Joined: 11 months ago

Posts: 0

My paths are just for example but not for use.
Can you show what do you tried?

(@ice-boy)
Joined: 11 months ago

Posts: 0

here i added my folder path where i have the materials.

–example (change filename)
loadMatsFromLib @“C: emp\mymaterials.mat

(@gazybara)
Joined: 11 months ago

Posts: 0

No. Here you need to add filename of your *.mat file
something like @“C:\yourdirectory\vrayLib.mat
But for second function U can use only directory path like @“C:\yourdirectory

could the script be so that its opens the window for selecting the .mat file?

thanks

once loaded the library can’t be reloaded. 50 extra materials in the scene shouldn’t be a problem, it they are not real-time shaders.
so you need simply UI to get easy command access to a list of material libraries:

load temp library

load a material to the editor

save library

1 Reply
(@ice-boy)
Joined: 11 months ago

Posts: 0

but every material has a seperate Material Library in the slate window.

Try this tools:
[color=YellowGreen]ML2ME
SMES
MatManager[/color]
MaterialLibraryLoader
V-Ray Material Library
Some work and some not

2 Replies
(@denist)
Joined: 11 months ago

Posts: 0

ML2ME+ a little modification will good enough

(@gazybara)
Joined: 11 months ago

Posts: 0

I agree. He wants ME solution not SME. Only with custom tool U can work without limitation of 24:)
Edit: And Here Comes the Boom!!! Nice and simple.

do you say that? why? you can simply open a material that you want to edit in the active material slot (or slate window).

how?

thanks

Page 1 / 2