ScriptSpot

Forum topic · General Scripting

Select Vraylight and off

By kimarotta · 2012-05-07

Description

Hi,

I have a problem in one script and I'm need a help please.

I am selecting a series of lights, some VRayLight and others do not. To turn off some lights use $lights.enabled = off, but some lights use the command $lights.on = off as an example are the photometrics and Vraylights ... When I use $lights.on = off gives the following error "- Unknown property:" on "in $ VRaySun: @ Sun_Cam_portaria [149.746979, -227.845520,0.000000]" How do we work? There is a class for vraylights?

thanks

Kim

Comments (6)

barigazy · 2012-05-07

Just create rollout with two buttons ("On" and "Off")
and then you can toggle lights on-off.
Cheers!

kimarotta · 2012-05-07

Very very good.

worked very well
perfect and clean

Just put the basic script I'm doing.

Thanks...

barigazy · 2012-05-07

And this is the shorter version
Tested and works fine.
Also work on the Daylight System
Now supports and FinalRender Lights


fn TurnTheLights state: =
(
if selection.count != 0 do
(
local lightTypes1 = #("Light", "mr Area Omni", "mr Area Spot", "VRayIES", "VRayAmbientLight", "VRaySun", "fRParticleLight")
local lightTypes2 = #("Skylight", "Photometric Light", "mr Sky Portal", "VRayLight", "RectLight", "fRDome", "CylinderLight", "fRParticleLight")
for lgh in selection where isKindof lgh Light do
(
if finditem lightTypes1 (getClassName lgh) != 0 then (lgh.enabled = state)
else if finditem lightTypes2 (getClassName lgh) != 0 do (lgh.on = state)
)
)
)
--Now you can set state on or off
TurnTheLights state:off --turnoff lights
--TurnTheLights state:on --turnon lights

good

kimarotta · 2012-05-07

Hey Man very thanks...

I will test and send feedback..

barigazy · 2012-05-07

I added twice "VRayAmbientLight".
I corrected the previous code.Copy again and try.

TurnTheLights (ON or OFF)

barigazy · 2012-05-07

You decide which state you need (on or off)
Supports all: VrayLights, mrLights, Standard and Photometric
Use this function.


fn TurnTheLights state:off =
if selection.count != 0 do
(
for lgh in selection where isKindof lgh Light do
(
case getClassName lgh of (
("Light"): lgh.enabled = state
("Skylight"): lgh.on = state
("Photometric Light"): lgh.on = state
("mr Sky Portal"): lgh.on = state
("mr Area Omni"): lgh.enabled = state
("mr Area Spot"): lgh.enabled = state
("VRayLight"): lgh.on = state
("VRayIES"): lgh.enabled = state
("VRayAmbientLight"): lgh.enabled = state
("VRaySun"): lgh.enabled = state
)
)
)
TurnTheLights state:off