check scene for lights
Hi all,
I am writing a script that will do this:
1. Check if there are lights in the scene.
2. If there are no lights, create 3 point lighting and then link it to a point helper object.
3. But if there are lights in the scene, don't create new lights, select the lights and pass it into an empty array.
The problems I am having are that I can't seem to get the script to check the scene for lights.
Cheers
/Saij
Here is my code:
(
sLights = #()
if sLights.count != 0
then append sLights (for l in lights where ClassOf l != light collect l) else
fn lightCreate = --Ligh Creator
(
local alignObj = Point pos:[0,0,0] size:25 box:true cross:false Name:"AlignObj"
local keyLight = TargetDirectionallight name:(uniqueName"KeyLight") rgb:(color 255 255 255) shadowColor:(color 0 0 0) multiplier:1 pos:[600,-540,540] isSelected:on target:(Targetobject transform:(matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0]))
local fillLight = targetSpot name:(uniqueName "FillLight_" rgb:(color 255 255 255) multiplier:0.5 pos:[-890,-630,410] isSelected:on target:(Targetobject transform:(matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0]))
local rimLight = targetSpot name:(uniqueName "RimLight_") rgb:(color 255 255 255) multiplier:0.3 pos:[-100,890,70] isSelected:on target:(Targetobject transform:(matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0]))
lightArray = (for l in lights where ClassOf l != light collect l)
lightArray.parent = alignObj
)
append sLights (lightCreate())
)
Comments
Thanks guys
Thanks guys,
I am save yet again, thanks so much.
Cheers
/saij
Yep, you are right. That is
Yep, you are right. That is better solution for sure.
I convert lights collection to array because Saij
mentioned in #3 question. But no need to select lights to create array.
bga
no prob ;)
my tips was written to Saij.
my recent MAXScripts RSS (archive here)
Yes, Lights is builtin dynamic collection
You can convert that collection to Array using As operator, but if that's the whole script, I not see a reason to do that. Also I see that you'll link your lights to a Point helper in both cases, so why not to create that Point and then if no lights
(lights.count == 0)
create only new lights with your function, and finally link them, i.e. something like this:my recent MAXScripts RSS (archive here)
one more example
you can also use point helper as target object
bga
try this one
bga