Skylight on/off from macros/scripts?



Hi- I know in V5 it was not possible to access and set the Skylight option from command line or script.
Can we have this ability in V6? A command to set On/Off/Toggle would be a good start.



(Pascal Golay) #2

Hi Jarek - yeah - is an ‘experiment’ to see how it flies… Nothing cast in stone here yet.



Hi Pascal - do you know if there is now any way to use command/macro or script to toggle the skylight on/off ?

(Nathan 'jesterKing' Letwory) #4

With Python you can use

import scriptcontext as sc

# toggle the skylight status
sc.doc.Lights.Skylight.Enabled = not sc.doc.Lights.Skylight.Enabled


Thanks Nathan.
How would I go about finding it myself in Python Editor help ?? ( I tried based on your sample, but could not locate any info).

I was actually hoping for a command version that does the same that I can use inside RhinoScript…
Oh well, this one seems to work: :stuck_out_tongue_winking_eye:

Option Explicit
Call RunPythonInRhinoScript()
Sub RunPythonInRhinoScript()
	Dim s : s = ""
	s = s & "import scriptcontext as sc" & vbCrLf
	s = s & "sc.doc.Lights.Skylight.Enabled = not sc.doc.Lights.Skylight.Enabled" & vbCrLf
	Call Rhino.Command("_-RunPythonScript (" & s & ")", False)
End Sub

(Nathan 'jesterKing' Letwory) #6

I don’t know about how well the help works - I find it quite hard to search for info as well, but I used mostly autocompletion and the left-hand namespace thingy of the python editor.


I think we should do better on documentation. We have lots of samples and all that, but I still find myself grappling with the APIs and the Hows.


You would need to look in the RhinoCommon online help.!

scriptcontext refers to the active doc - it is your “gateway” to objects already in the document, the various tables such as objects, layers, views, lights, etc…

So in this case, as it’s a light, you would need to look in the light table. sc.doc.Lights references the light table, but the api reference would be Rhino.DocObjects.Tables.LightTable, from there you can find Skylight and from there you can find its Properties which include Enabled - which you can Get (read) or Set (write)…

At least that’s how I find stuff…


Thanks guys, very helpful info.