Chaos Corona Forum

Chaos Corona for 3ds Max => [Max] I need help! => Topic started by: cecofuli on 2016-11-09, 14:55:11

Title: Import all materials inside .mat in the empty MEdit: how?
Post by: cecofuli on 2016-11-09, 14:55:11
Hello,

the situation is this:
(*)  I have some .mat files.
(*) In every .mat file I have 5-10-15 shaders.
(*) I have an empty MEdit
(*) How can I populate the Medit with the shaders inside the .mat file without to click 5-10-15 times?
Title: Re: Import all materials inside .mat in the empty MEdit: how?
Post by: maru on 2016-11-09, 15:35:09
This is probably possible via maxscript, but since I have 0 maxscript knowledge, here is a funny workaroud I can think of:
(based on https://coronarenderer.freshdesk.com/support/solutions/articles/5000571040)

Go to C:\Users\your_user_name\AppData\Local\Autodesk\3dsMax\2016 - 64bit\ENU\en-US\defaults\MAX and save your file as Medit.mat. It should be automatically loaded into your meditor once 3ds MAx is launched. :)
Title: Re: Import all materials inside .mat in the empty MEdit: how?
Post by: cecofuli on 2016-11-09, 15:39:02
Ahaha... funny solution XD
but I have a looot of .mat files.

With 3ds Max you can import only one shader at time (who is insie the .mat).
But, we cannot import all the shaders, or some of them, in the Empty MEdit. It's so strange...

What I want is to transfer all .mat shader inside the 24 Samples slot.
It's a boring task to click on one shader at time.
As you, I have 0 maxscript knowledge =)


In the slate editor, we can open a .mat file and we can drag & drop the shaders in the .mat  to the Samples slot.
It's a faster solution but... again, it's a boring task.
Title: Re: Import all materials inside .mat in the empty MEdit: how?
Post by: racoonart on 2016-11-09, 16:26:58
Here you go:

Code: [Select]
(
libPath = getOpenFileName caption:"Open a material library" types:"Matlib (*.mat)|*.mat"

matlib = loadTempMaterialLibrary libPath
for i = 1 to matlib.count while i <= 24 do meditmaterials[i] = matlib[i]
)

You can save it as a .ms or make a macroscript and bind it to a button :)
Title: Re: Import all materials inside .mat in the empty MEdit: how?
Post by: cecofuli on 2016-11-09, 17:21:13
O god. it's so cool!!! O_O
Thansk! I don't understand why Autodesk doesn't add this simple tool in the MEdit...
Title: Re: Import all materials inside .mat in the empty MEdit: how?
Post by: Jahman on 2016-11-09, 20:28:38
Bet one day you'll have more than 24 materials in such a lib file ;)

Code: [Select]
(
libPath = getOpenFileName caption:"Open a material library" types:"Matlib (*.mat)|*.mat"
matlib = loadTempMaterialLibrary libPath

fn exec action = (
MatEditor.mode = #advanced
MatEditor.close()
MatEditor.open()
actionMan.executeAction 369891408 action

)

with redraw off (
TabName = "Some default tab name " + (sme.GetNumViews() as string)
MatEditor.close()
SME.CreateView TabName
MatEditor.open()

view = sme.GetView (sme.GetViewByName TabName)

for mtl in matlib do view.createnode mtl [0,0]

exec "40063" -- select all nodes
exec "40075" -- hide unused nodeslots
exec "40060" -- lay out all nodes in SME tab
exec "40064" -- deselect

)
)
Title: Re: Import all materials inside .mat in the empty MEdit: how?
Post by: cecofuli on 2016-11-15, 17:58:40
DeadClown,
your script is great! I use it all days =)
But, I have a little request:

When I run the script, a new "Open Material library" dialog will open.
But, if I want to close this window, with the "X" button on the top right side, I have a script error.
Maybe because 3ds Max is waiting for my .mat selection.
So, how can I fix this small problem?

Thanks!
Title: Re: Import all materials inside .mat in the empty MEdit: how?
Post by: Jpjapers on 2016-11-15, 23:02:43
Ask and you shall recieve



[ SNIP ]
Title: Re: Import all materials inside .mat in the empty MEdit: how?
Post by: cecofuli on 2016-11-15, 23:38:38
It doesn't work.
Title: Re: Import all materials inside .mat in the empty MEdit: how?
Post by: Jpjapers on 2016-11-16, 09:27:45
Hmm it worked on my machine... Perhaps someone else can do something with the 24 or more mats code.
Sorry
Title: Re: Import all materials inside .mat in the empty MEdit: how?
Post by: racoonart on 2016-11-16, 09:42:11
When I run the script, a new "Open Material library" dialog will open.
But, if I want to close this window, with the "X" button on the top right side, I have a script error.

Whoops. Noob mistake :D  95% of all my bugs are because I don't check the input :X

Code: [Select]
(
libPath = getOpenFileName caption:"Open a material library" types:"Matlib (*.mat)|*.mat"

if libPath != undefined then (
matlib = loadTempMaterialLibrary libPath
for i = 1 to matlib.count while i <= 24 do meditmaterials[i] = matlib[i]
)
)
Title: Re: Import all materials inside .mat in the empty MEdit: how?
Post by: cecofuli on 2016-11-17, 23:08:02
Thanks so much! Not it works well!  =)