[Closed] Collect all Lights in Dropdownlist
Hi there,
I’m strugglin with the above problem.
All I want to do is that all lights in my scene get collected into a dropdownlist at launch of the script. currently I have the following:
dropdownlist ddlLightList "LightList:" align:#center
items:#(
for i in (lights as array) do (
append ddlLightList.items i.name
)
)
Ok I got this done, all my lights appear with their names as strings in the dropdownlist.
But how can I now select them from that dropdownlist?
I got:
on ddlLightList selected i do (
select ((ddlLightList.selected) as name)
)
This should do the trick:
execute (“select $” + ddlLightList.selected)
Also make sure when you’re collecting the lights that you check the “superclassof(i) == light” because the other way around it will also collect targets from the lights.
Cheers.
You can also use
getNodeByName
But I prefer something like this:
(
...
local lightsArray
dropdownlist ddlLightList "LightList:"
on roll open do (
lightsArray = lights as array
ddlLightList.items = for o in lightsArray collect o.name
)
on ddlLightList selected arg do (
select lightsArray[arg]
-- or select lightsArray[ddlLightList.selection]
)
...
)
Because it’s name independent, namely you won’t have trouble selecting lights that have duplicate names or lights that have changed their name since the list was populated.
This might not be so important in this case but it’s a good practice.
Thank you both!
If it’s good practice to do so, I will, too.
Well that problem solved, another one arises:
Bay what code I do check if there’s any new light created or deleted while the script is open? So I can append that to the ddl.
I figured I have to use some sort of callback? But which one?
EDIT:
Found it, it’s [b]#sceneNodeAdded
[/b]Well, I also want to call the callback function when I delete a light! So I tried #nodePostDelete but I tested it with this second callback, (with a pring) and it seems the Callback doesnt register when i select a light and press [del].
With #nodePreDelete the cb is detected, but since the cb function gets executed prior to the deletion of the node, this node still shows up in the lights list, and the one i deleted prior to it is correctly NOT showing up…
Is there any way to check for this kind of node deletion ?
camthing = #("------Select Camera------")
sceneCam = for o in cameras where classof o != TargetObject collect o
sceneCamNames = camthing + (for o in sceneCam collect o.name)
rollout ""
(
dropdownList ddl_cam "" pos:[105,1] width:18 height:21 items:sceneCamNames toolTip:"Select Scene Cams."
on ddl_cam selected i do
(
if ( i > 0 ) then try(select sceneCam[i-1])catch(
sceneCam = for o in cameras where classof o != TargetObject collect o
sceneCamNames = camthing + (for o in sceneCam collect o.name)
RappaToolsUI.ddl_cam.items = sceneCamNames
)
if ( i == 1 ) then
(
sceneCam = for o in cameras where classof o != TargetObject collect o
sceneCamNames = camthing + (for o in sceneCam collect o.name)
RappaToolsUI.ddl_cam.items = sceneCamNames
)
)
)