Author Topic: [RESOLVED] Assign CoronaMtl From Material Library with Script  (Read 1315 times)

2019-09-09, 04:38:28

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
I'd like to create a button in the toolbar that will assign a specific material in a material library to any selected object. I've looked around for some time and found:

Code: [Select]
$.material = CoronaMtl()
$.wirecolor = color 0 0 0

This assigns a default Corona Material, but if I'd like to assign a custom Corona Material from a material library, this script will not suffice. Any suggestions?
« Last Edit: 2019-09-09, 23:50:48 by cjwidd »

2019-09-09, 06:48:36
Reply #1

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
This does the trick, but in the wrong way, i.e. it creates a material and assigns it, but I want to pull a material from an existing library and assign it.

Code: [Select]
theMat = CoronaMtl ()
theMat.colorDiffuse = color 117 117 117
theMat.levelReflect = 1.0
theMat.reflectGlossiness = 0.1
theMat.name = "middle_gray_(18%)"
$.material = theMat

2019-09-09, 08:53:49
Reply #2

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
Solution:

Code: [Select]
tempMatLib = loadTempMaterialLibrary @"C:\Users\[USERNAME]\Documents\3dsMax\materiallibraries\[MATLIBRARYNAME].mat"
if tempMatLib != undefined do
(
$.material = tempMatLib["cw_cyan"]
)
« Last Edit: 2019-09-09, 10:37:50 by cjwidd »