Author Topic: Import all materials inside .mat in the empty MEdit: how?  (Read 7744 times)

2016-11-09, 14:55:11

cecofuli

  • Active Users
  • **
  • Posts: 1577
    • View Profile
    • www.francescolegrenzi.com
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?
« Last Edit: 2016-11-09, 15:26:06 by cecofuli »

2016-11-09, 15:35:09
Reply #1

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 12768
  • Marcin
    • View Profile
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. :)
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2016-11-09, 15:39:02
Reply #2

cecofuli

  • Active Users
  • **
  • Posts: 1577
    • View Profile
    • www.francescolegrenzi.com
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.

2016-11-09, 16:26:58
Reply #3

racoonart

  • Active Users
  • **
  • Posts: 1446
    • View Profile
    • racoon-artworks
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 :)
« Last Edit: 2016-11-09, 16:33:20 by DeadClown »
Any sufficiently advanced bug is indistinguishable from a feature.

2016-11-09, 17:21:13
Reply #4

cecofuli

  • Active Users
  • **
  • Posts: 1577
    • View Profile
    • www.francescolegrenzi.com
O god. it's so cool!!! O_O
Thansk! I don't understand why Autodesk doesn't add this simple tool in the MEdit...

2016-11-09, 20:28:38
Reply #5

Jahman

  • Active Users
  • **
  • Posts: 45
  • Panteleev Sergey
    • View Profile
    • some of my scripts for 3ds max
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

)
)

2016-11-15, 17:58:40
Reply #6

cecofuli

  • Active Users
  • **
  • Posts: 1577
    • View Profile
    • www.francescolegrenzi.com
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!

2016-11-15, 23:02:43
Reply #7

Jpjapers

  • Active Users
  • **
  • Posts: 1654
    • View Profile
Ask and you shall recieve



[ SNIP ]
« Last Edit: 2016-11-16, 09:28:43 by jpjapers »


2016-11-16, 09:27:45
Reply #9

Jpjapers

  • Active Users
  • **
  • Posts: 1654
    • View Profile
Hmm it worked on my machine... Perhaps someone else can do something with the 24 or more mats code.
Sorry
« Last Edit: 2016-11-16, 09:33:27 by jpjapers »

2016-11-16, 09:42:11
Reply #10

racoonart

  • Active Users
  • **
  • Posts: 1446
    • View Profile
    • racoon-artworks
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]
)
)
Any sufficiently advanced bug is indistinguishable from a feature.

2016-11-17, 23:08:02
Reply #11

cecofuli

  • Active Users
  • **
  • Posts: 1577
    • View Profile
    • www.francescolegrenzi.com