rheinason
(Rheinason)
March 19, 2020, 11:50pm
1
Hi there! I’ve been racking my brain on this seemingly simple script. I wanted to create a script where I could control the north direction of the document sun by setting two points. I just can’t seem to figure out a way to control the document sun north? I can find the property with ScriptContext:
import scriptcontext as sc
sun = sc.doc.Lights.Sun
print(sun.North)
But I’m unsure of how I’d set the sun north.
Holo
March 20, 2020, 12:12am
2
You might find some help in looking at the example here:
I dug through my old script bits (from a pretty cool sun study ramp image generator I made for inhouse use) that might help you along:
You have to turn on SUN and the global position in the panel first though. This is just to set the sun.
### Simple set hour for sun study by HOLO ###
import Rhino
import rhinoscriptsyntax as rs
def SetDateTime(YEAR,MONTH,DAY,HOURS,MINUTES):
from datetime import datetime
date = datetime(YEAR, MONTH, DAY, HOURS, MINUTES)
print "DATE "+str(YE…
(I am not at pc now)
rheinason
(Rheinason)
March 20, 2020, 1:50am
3
That indeed did the trick! Here’s the little script I ended up with:
import Rhino
import rhinoscriptsyntax as rs
import math
ln = rs.GetLine(1, None, "First point", "Second point")
dir = ln[1] - ln[0]
angle = math.degrees(math.atan2(dir.Y,dir.X))
angle = round((angle+360) % 360,1)
if angle == 360:
angle = 0
print(angle)
RhinoSun = Rhino.RhinoDoc.ActiveDoc.Lights.Sun
Rhino.Render.Sun.North.SetValue(RhinoSun,angle)