Skylight on/off from macros/scripts?

unhandled

#1

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.

thanks,

–jarek


(Pascal Golay) #2

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

-Pascal


#3

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

#5

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.

image

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.


#7

You would need to look in the RhinoCommon online help.

http://developer.rhino3d.com/api/RhinoCommon/html/N_Rhino.htm#!

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…


#8

Thanks guys, very helpful info.