[RESOLVED] Assign CoronaMtl From Material Library with Script

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:


$.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?

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.


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

Solution:


tempMatLib = loadTempMaterialLibrary @"C:\Users\[USERNAME]\Documents\3dsMax\materiallibraries\[MATLIBRARYNAME].mat"
if tempMatLib != undefined do
(
	$.material = tempMatLib["cw_cyan"]
)