Rhino8 sun SetPosition obsolete?

Hello everyone,

I was trying to manipulate sun’s positioning from GH for the first time in Rh8, but I have noticed the latest updates for it. For instance, SetPosition is obsolete as written in the latest rhinocommon site. At the same time I couldn’t use other methods like setDirection or so.

Please, kindly let me know what I am missing within the code. I will write the code I am writing below:

import Rhino
from System import DateTime

date = DateTime(y, mon, d, h, mnt, 0)

sun = Rhino.RhinoDoc.ActiveDoc.Lights.Sun
sun.SunDirection(lat, lon, date)

sunVec = sun.Vector

And is there any other method or namespace to set date and time manually/parametrically?

Thanks,
Mehrzad

SunDirection is a static method.
You can get the vector by simply storing the return value like so:
sunVec = Rhino.Render.Sun.SunDirection(lat, lon, date)

To “set position” of the sun you can change the object’s properties directly:

sun.Latitude = 23.5
sun.Longitude = 11.1
2 Likes

Thank you, Will. It is working now.

There is a component also in Grasshopper in Rhino 8 that also deal with the sun, its position and its path.

2 Likes

Thank you for the reminder. I had heard about this before but forgot about it. And thanks for sharing the screenshot. Helps a lot.