sun.Azimuth sun.Altitude for different dates with python

Hi,

I can get the values for Azimuth and Altitude from scriptcontext.doc.Lights.Sun.Azimuth and scriptcontext.doc.Lights.Sun.Altitude

But those are only the values for the date that is set in the Rhino document.
Is it possible to get values for several dates using a python script?

Thank you!

Can you set the date?

In the Rhino Document, yes. And it gets picked up by scriptcontext.doc.Lights.Sun
But I don’t know how to input a list of values for multiple dates.

Hmm. Yes, digging in to Rhino.DocObject via Python I get errors if I try to access AnimationSettings. I don’t know if I am doing this correctly

@piac is it possible to set the date via Python?
Thanks, graham

@Dancergraham Actualy you don’t need to change the date for Rhino Document Sun. You can create a non-document controlled Sun set the postition of it and then get the Altitude and Azimuth.

import ghpythonlib.components as ghp
import Rhino

date = ghp.ConstructDate(2019,month,day,hour,minute,0)
mySun = Rhino.Render.Sun()
Rhino.Render.Sun.SetPosition(mySun, date, latitude, longitude)

Altitude = mySun.Altitude
Azimuth = mySun.Azimuth


Bogdan_Chipara.gh (21.2 KB)

2 Likes

You can do it if you want to, but it will run much slower.

import ghpythonlib.components as ghp
import Rhino

date = ghp.ConstructDate(2019,month,day,hour,minute,0)
RhinoSun = Rhino.RhinoDoc.ActiveDoc.Lights.Sun
Rhino.Render.Sun.SetPosition(RhinoSun, date, latitude, longitude)

Altitude = RhinoSun.Altitude
Azimuth = RhinoSun.Azimuth

Graham.gh (18.5 KB)

1 Like

ok, @Mahdiyar, it works well, thanks. Indeed, better not to change the datetime in rhino document.
I had to test in R6, in 5 it doesn’t work.