macroScript CoronaIesPresets category:"ebbmaxscript" icon:#("Lights", 1) ( global CoronaIesPresets try (destroydialog CoronaIesPresets) catch() local theIni = (GetDir #userScripts) + "\\coronaIesPresets.ini" rollout CoronaIesPresets "CoronaIesPresets 1.02" ( button refresh "R" pos:[81,3] tooltip:"refresh the lights list" button help "?" pos:[106,3] tooltip:"help" button folder "F" pos:[235,3] tooltip:"set default folder" ListBox lightList "CoronaLights:" height:10 width:120 pos:[7,10] ListBox iesList "Ies List:" height:10 width:120 pos:[137,10] checkbox onCB "On" checked:true pos:[8,169] enabled:false spinner intensity "Intensity" range:[0,100000,0] type:#float width:75 pos:[71,170] enabled:false groupBox Group1 "Color" pos:[4,190] width:142 height:61 radiobuttons colorMode labels:#("DirectInput","KelvinTemp") default:0 columns:1 pos:[9,210] enabled:false colorpicker directInputColor "" color:black fieldWidth:40 height:15 pos:[84,208] modal:false title:"CoronaIesPresets" enabled:false spinner KelvinTemp "" range:[1000,99999,3000] type:#integer width:55 pos:[86,225] enabled:false button start "Start" width:100 height:80 pos:[154,171] tooltip:"start corona interactive rendering" group "info:" ( label info "..." align:#left ) local iesFolder local lightSelection = undefined local theLight fn getAllCoronaLights = ( local theLights = #() for l in lights where classOf l == CoronaLight do ( local instances if (InstanceMgr.GetInstances l &instances) >= 1 do ( if findItem theLights instances[1] == 0 do join theLights instances[1] ) ) theLightsArr = for l in theLights collect l.name sort theLightsArr theLightsArr ) fn setui state = ( onCB.enabled = state intensity.enabled = state colorMode.enabled = state directInputColor.enabled = state KelvinTemp.enabled = state ) fn getValues theNode = ( onCB.enabled = true onCB.checked = theNode.on intensity.enabled = true intensity.value = theNode.intensity local theText = theNode.iesFile if theText != undefined then info.text = "iesFile: " + filenameFromPath theText else info.text = "iesFile: none" case theNode.colorMode of ( 0: ( colorMode.enabled = true colorMode.state = 1 directInputColor.enabled = true directInputColor.color = theNode.color KelvinTemp.enabled = false ) 1: ( colorMode.enabled = true colorMode.state = 2 directInputColor.enabled = false directInputColor.color = black KelvinTemp.enabled = true kelvinTemp.value = theNode.blackbodyTemp ) 2: ( colorMode.enabled = false colorMode.state = 0 KelvinTemp.enabled = false directInputColor.enabled = false directInputColor.color = black ) ) ) fn saveToIni thekey thevalue = ( setIniSetting theIni "Defaults" thekey thevalue ) fn openGroups collection = ( with redraw off ( for o in collection where isGroupHead o do ( setGroupOpen o true ) ) ) on refresh pressed do ( lightList.items = getAllCoronaLights() lightList.selection = 0 lightSelection = undefined info.text = "..." if lightList.items.count == 0 do messageBox "No CoronaLight in the scene!!!\nCreate at least one first." title:"CoronaIesPresets" ) on help pressed do ( local theString = "- Set your Default Folder for your Ies.\n" theString += "- Select Light from the List.\n" theString += "- Assign Ies from the Ies List.\n" theString += "- Press Start for Interactive Rendering.\n" theString += "- Change Basic Parameter as needed.\n" theString += "- DoubleClicked on the Light to Remove the Ies.\n" theString += "\n\nScript by: oncire 2015" messageBox theString title:"Help" ) on folder pressed do ( local f = getOpenFileName caption:"Select IES" types:"IES(*.ies)|*.ies|" if f != undefined do ( iesFolder = getFilenamePath f local p = iesFolder + "*.IES" local files = getFiles p iesList.items = (for i in files collect filenameFromPath i) iesList.selection = 0 saveToIni "defaultFolder" iesFolder ) ) on lightList selected arg do ( max create mode lightSelection = lightList.items[arg] theLight = execute ("$" + lightSelection) if (IsValidNode theLight) then ( select theLight openGroups $ select theLight iesList.selection = 0 getValues theLight ) else ( lightList.items = getAllCoronaLights() lightList.selection = 0 lightSelection = undefined ) ) on lightList doubleClicked arg do ( theLight.iesFile = "" info.text = "iesFile: none" ) on iesList selected arg do ( local iesSelection = iesList.items[arg] if lightSelection != undefined and (IsValidNode theLight) do ( theIesPath = iesFolder + iesSelection theLight.iesOn = true theLight.iesFile = theIesPath info.text = "iesFile: " + filenameFromPath theIesPath ) ) on iesList rightClick arg do ( iesList.selection = 0 ) on lightList rightClick arg do ( setui false lightList.selection = 0 lightSelection = undefined info.text = "..." directInputColor.color = black ) on intensity changed arg do ( theLight.intensity = arg ) on onCB changed arg do ( theLight.on = arg ) on colorMode changed arg do ( case arg of ( 1: ( theLight.colorMode = 0 directInputColor.enabled = true directInputColor.color = theLight.color KelvinTemp.enabled = false ) 2: ( theLight.colorMode = 1 directInputColor.enabled = false directInputColor.color = black KelvinTemp.enabled = true kelvinTemp.value = theLight.blackbodyTemp ) ) ) on directInputColor changed arg do ( theLight.color = arg ) on KelvinTemp changed arg do ( theLight.blackbodyTemp = arg ) on start pressed do ( if (matchPattern (renderers.current as string) pattern:"Corona*") do ( CoronaRenderer.CoronaFp.startInteractive() ) ) on CoronaIesPresets open do ( max create mode if (doesFileExist theIni) == true do ( iesFolder = getINISetting theIni "Defaults" "defaultFolder" local p = iesFolder + "*.IES" local files = getFiles p iesList.items = (for i in files collect filenameFromPath i) iesList.selection = 0 ) lightList.items = getAllCoronaLights() lightList.selection = 0 ) ) if (matchPattern (renderers.current as string) pattern:"Corona*") then ( clearSelection() createdialog CoronaIesPresets width:263 height:300 style:#(#style_toolwindow, #style_sysmenu) ) else ( messageBox "Switch Renderer to Corona First!!!" title:"CoronaIesPresets" ) )