Select the light mix list item by light

Is there a way to select the light mix list item by light? You know, On the contrary, we can do it. I want to do that in Maxscript or C# .

You can reference this post about the lightmix, which has valuable information on scripting the lightmix:
https://forum.corona-renderer.com/ Maxscript access to LightMix

From that post I put this together for you, you can also use more loops to do other stuff but the basics are here. Its a bit quick so you can clean it up for your use but you should get the point:


coronaLights = #()
for i in getclassinstances CShading_LightSelect do
(
    -- Adds array, eg Light_Select 2 might have 3 lights, etc.
    append coronaLights i.includedNodes
) 

-- select the light in the first Light_Select - 1 light in this array
select coronaLights[1][1]

Also if you want to select all the lights in say Light_Select 2, remove the last line (select coronaLights[1][1]) and use this instead:


--select the lights in the second Light_Select - 2 or more lights in this array
lightSel = for j in coronaLights[2] collect j 
select lightSel

Or just have it do multiple for loops, like for i in coronaLights for j in i etc..

Hi James Velia, Maybe I wasn’t clear enough. I mean when I select a light in the scene ,LightMix Item was selected in FVB UI . so I can know some LightMix Item need to change color or intensity. this saves searching time. Otherwise finding the right one among dozens of lights is not simple thing.

Well I dont know how to access the UI but you can use this instead, select a light and run this script, it will give you a messagebox with the Light Select Elements name:


-- Struct to hold LightSelect Element and Lights associated to that Element
struct LightMixData 
(
	elementName,
	lights
)

-- Add the Lights & Elements to the Struct
lightMixTable = #()
for i in getclassinstances CShading_LightSelect do
(
	lightMixEntry = LightMixData()
	lightMixEntry.elementName = i.name 
	lightMixEntry.lights = i.includedNodes
	append lightMixTable lightMixEntry 
) 

-- Messagebox to show user the light element for selected light
fn ShowMessageForSelectedLight =
(
    -- Get the currently selected nodes
    selectedNodes = getCurrentSelection()
    if selectedNodes.count == 0 then exit

    for node in selectedNodes do
    (
        if isKindOf node Light do
        (
            elementName = for entry in lightMixTable where findItem entry.lights node != 0 collect entry.elementName

            if elementName.count > 0 then
                messageBox ("Element Name: " + elementName[1] + "\nLight Name: " + node.name)
            else
                messageBox("Element Name not found for: " + node.name)
        )
    )
)

-- Run Main Function
ShowMessageForSelectedLight()

Edit:
I think access to Lightmix via maxscript is currently in development (by user request). Once this is rolled out we should have access directly to the value/color in the lightmix which would be great because we can extend this script and build a little UI so when you select a light you can directly change properties in the lightmix as needed.