Radiance modules headless

Hi everyone,

My current project consists in running Rhino and Grasshopper headless, from a python script, using the rhinoinside package. I have a Grasshopper file that i pretty much want to “translate” in python script, and it works pretty well, I can access a lot of different packages, which translate in extensions in grasshopper like ladybug, ladybug_rhino, ladybug_radiance. I am especially using the LB Incident Radiation, LB Cumulative SkyMatrix, LB Real Time Incident Radiation, ImportEPW and finally Analysis period.
This allows me to get the irradiance data under surfaces representing solar panels, hour by hour during the whole year, from python scripts, where I mainly imported code from grasshopper definitions.
The code is working perfectly well, I am able to have 8760 data corresponding to the irradiance of every single hour of the year. The only issue I face is that this data is the same regardless of the size, angles, lenght, width of the “context_”. The main goal of this project is to measure the ground irradiance under panels tracking the sun, so the “context_” needs to vary a lot.
The only way I found to create surfaces that works with Incident Radiation, from a python script is this one :

  • Create and fill a Point3dList, named p
  • Create and fill a PolylineCurve with p named C
  • Create a surface from the RhinoGeometry function RhinoSurface.CreateExtrusion taking in input C and an orthogonal Vector3d to create a thin thickness
  • Transform all thoses surfaces according to my needs, with Rhino.Geometry.Transform (angles, orientation, etc …)
  • Converting them to a Brep using Rhino.Geometry.Surface.ToBrep()

The Brep is the object sent into the Incident Radiation function, more precisely under a list form because of this particular code line in Incident Rad :
shade_mesh = join_geometry_to_mesh(_geometry + [context_])
When I visualize the created Brep on Rhino I clearly see that it is very similar to what I had in the Grasshopper file, but I still suspect my way of creating the surface to be the source of my problems. The Incident Radiation Function is the exact same grasshopper definition, I copied and pasted it.

If you, from what is above, have any ideas of what I could modify, or I what I could test to find the exact origin of my mistakes, I take everything.
Also feel free to ask for more informations that could help, I may have not explained it in the best way.

Here is the github repo, please take a look if you’re highly motivated and willing to lose hair, it’s not disgusting code but I’m still a beginner.

Thanks a lot, and have a nice day !


Update, I found the solution, to create a surface I now use the way simplier :

def create_surface(x, y, width, length):
    Create a simple NURBS Rhino Surface, from one of its four angles and its dimensions (width, length)

    Args :
    x (float) : X-coordinate of origin angle
    y (float) : Y-coordinate of origin angle
    width (float) : width of the surface
    length (float) : length of the surface

    Return :
    surface (Rhino.Geometry.NurbsSurface) : Surface created
    pt1 = rg.Point3d(x, y, 0)
    pt2 = rg.Point3d(x, y + width, 0)
    pt3 = rg.Point3d(x + length, y + width, 0)
    pt4 = rg.Point3d(x + length, y, 0)
    # Create a point list
    points = [pt1, pt2, pt3, pt4]

    # Create a surface from the previous point list, and return it
    surface = rg.NurbsSurface.CreateFromCorners(pt1, pt2, pt3, pt4)
    return surface

Following this, I had an issue with the direction of all the surfaces normals, but quickly fixed with :

brep_surf = surface.ToBrep()