Plotting results for sunlight hours analysis

Hello everyone,

I’m sorry if this has been asked before, have searched through the forum but could not find anything similar.

I’m trying to do a direct sunlight analysis on the window geometry. The windows and most of the geometry are imported from Rhino. First I tried to deconstruct the windows (breps) into surfaces to only get the outer window pane (2-glass-windows). However, the results seems odd due to the normals became wrong on some sides due to that there are windows in all directions. However that is another problem…

So what I want to do is to display by the mesh the windows that get at least 1 hour of direct sunlight per day on 20th mars. On top of that I want to plot the total numbers of direct sunlight on every window.
I have 2094 breps (windows) to analyze with a grid size of 0.1m and a time step of 15 mins and 23816 branches of results. So there is a varying number of test points on the windows since they have different sizes.

How can I get the avarage number of hours over each window mesh, or instead only analyze the center point of each window? By then I might have the problem with normals facing wrong direction… I try to use the text tag component.

I have managed to visualize the result with green=at least 1 hour of sun, red=less. But I want every window to only get one result (pass/fail) together with the text showing total hours on the surface.

Kind regards, Julia


Hello julia-a,

I’m trying to do basically the same thing! Did you ever figure this out? I’ve been trying to “assign” the points to each window (brep) but I have more experience in Dynamo, and am still pretty new to grasshopper.

Any help would be greatly appreciated.


Hey @Stefan_L,

Using the latest version of the LB Direct Sun Hours component

If you’re not too familiar with GH I would set up all of your windows as individual surfaces in Rhino checking their normals are facing out.

Then in GH assign all those surfaces to a BREP component, input that into the _geometry input, and right click on _geometry and change it from flatten to graft.

Make sure to keep the context_ input as flatten.

Then you should get a data tree for all results, which you can average to get a single value per window.

Hello charlie.brooker,

Thank you for your reply!

ok, let me see,
I am currently running LB version 1.5.0
I’ve brought my windows into Rhino and made them into breps
(the context geometry is a mesh)
I changed the _geometry to “graft”

everything is great, but I’m not sure what an “average” would do for me…
i’m looking for the total amount of sunlight per window,

for example, if one point on a window get 1 hour of sunlinght from 10:00-11:00, and another point gets 1 hour of sunlight from 14:00-15:00, then the total sunlight for the window is 2 hours, even though each point only recieved 1 hour.

This seems to me that i need maybe a union of lists for each point? maybe i’m not familiar enough with grasshopper vocabulary, but an average would tell you the same window had only 1 hour. (and if a third point didn’t get any sunlight, the average would be 66 minutes.)

the int-mtx output seems to tell me at what times each point receives sun, what I think I need is a “union” of these values, for all the points on each window.

Am I going down the wrong path?

attached is a screenshot of two test windows with the context geometry hidden.

Kind regards, and thank you again for your help!

1 Like

Hey @Stefan_L,

What’s your aim?

Sounds like the logic you’re aiming for is:

  • for each window
  • for each hour does the sun hit any part of the window?
  • count the hours where the above statement is true

If that’s what you’re after you’ll need to use the HB version of the component to get hourly results to process.

It does up the complexity quite a bit, the LB version just gives the number of hours each point can see the sun, not when they can see the sun.

The more you can simplify your aim the simpler your script can be. For example, if you just wanted to know per window which point receives the most sun hours and return that as your result for the window that’s less complicated as you remove the time based element.

That’s how I’d go about it, but I think your idea of using the int_mtx should also work! :slight_smile:

What does int_mtx return? If it’s a 1/0 for sun hits/sun misses then definitely can use that. If you use LB Deconstruct Matrix and plug the output into a panel I could have a look.

Hoping that it then does give 1/0 per point, the list would then be by your sun vectors, where you’d go from there I can’t quite picture in my head - I’d first try to flip the matrix to hopefully give a list of each point for each hour per surface, then mass addition on that and use a > to test if the result is greater than or equal to 1, then flip the matrix back - probably need to do a path mapper to go from a;b;c to a;b and then mass addition on that to get number of sun hours per window.

Hopefully that’s roughly the right logic, bit tricky to visualise without trying it

int_mtx gives exactly that. each point has it’s test if it can “see” the sun at a given time, and the “yes/no” result is shown as 1 or 0. it’s a long list, I just haven’t yet learned in Grasshopper how to manage them yet…

here’s another screenshot of my messy unfinished GH script… zoomed in the int-mtx list.
I’ll try and figure out what you are describing and see if it works.


Nice, so if I’m right 0;0, or a;b a is the window, b is the point, and the returned list is if that point sees the sun or not.

This is definitely the tricky bit, I might just be failing to think of a simpler way to handle it. The first thing that comes to mind would be to graft it, so you have a;b;c where c is the the hour.

Then if you use path mapper and transform it from a;b;c to a;c then you’ll get a list for each hour of all points. Mass addition on that will give you total number of points that see the sun at each hour (per window).

Then if you plug the mass addition in to “>”, and have the input as 0 and plug the output of “>” into a number component, you can then use path mapper again to go from a;b to a and do a mass addition to get your final result

It’s messy but in my head it does the job

1 Like

I’m sorry charlie.brooker,

I’m still too new to grasshopper to understand your instructions.
(Recently converted from Dynamo)

I’m also too new to this forum to attach my .gh file. :frowning: If I had permissions I’d happily send it.

here is a screenshot of the relevant area showing the LB Direct Sun Hours, and the explanation from Ladybug for int_mtx…

Screenshot 2022-12-21 170842

I’ve not had a chance to learn how to use the HB Direct sunlight hours, do you know of a tutorial how to use it?

I’ve also been looking at this post Direct Sunlight Hours, points

Hi @Stefan_L,

Looks like you’re super close. For ease, these are the steps from XMatrix on:

  • graft the output of XMatrix (“values”)
  • plug that into path mapper
  • double click on path mapper and input a;b;c on the left and a;c on the right (now instead of lists of 1/0 results for each point you have lists 1/0 for each sun vector)
  • put the output of that into a mass addition component (the result will be the number of points on each window that can “see” the sun vector)
  • put the output of that into a Larger Than component, with 0 as the second number (we don’t care how many points can “see” the sun, only care if at least one point can, if none can it gives 0, if at least one can it gives 1)
  • now input that result into a new path mapper, in this path mapper put a;b on the left and a on the right (this will give a list of lists, where each list has a number of 1/0s for each sun vector on whether any points can “see” the sun for that vector)
  • you can then put that into a mass addition component to return the total number of hours any part of a window “see” the sun

Fingers crossed that all works, might’ve made some mistakes doing it in my head.

1 Like

It worked perfect! Thank you!

I think I’ll move on to the HB version next, because I’d like to get sunlight time per room as well. Is that the better component to use for that?

1 Like

Glad it worked!

Yep the HB and HB Radiance components are what I’d recommend.

The tutorials here are fantastic:

The geometry creation and grid-based analysis videos should give you a good basis that you can adapt for what you want to achieve.