Chaos Corona Forum

Chaos Corona for 3ds Max => [Max] I need help! => Topic started by: cjwidd on 2019-09-09, 04:38:28

Title: [RESOLVED] Assign CoronaMtl From Material Library with Script
Post by: cjwidd on 2019-09-09, 04:38:28
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?
Title: Re: Assign CoronaMtl From Material Library with Script
Post by: cjwidd on 2019-09-09, 06:48:36
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
Title: Re: Assign CoronaMtl From Material Library with Script
Post by: cjwidd on 2019-09-09, 08:53:49
Solution:

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