mergeVectors_ function of Ladybug_ShadingDesigner

Hi Mostapha,

I’ve created a good function to merge shading surfaces generated by LB shading designer.
It consist in a smart loop, I have done a couple of examples, here you can see what happens with 143 vectors, 290 vectors… The result of the present function is red and the one of my function is yellow…

This function could be useful when you connect multiple hours and multiple months:

The only limit should be the memory of a machine, but this depends by the case to solve, if it is complicated or not.


Hi Antonello, Nice work! What do you think is the next step? Should we integrate it into the component itself so in case the old method failed to join the curves the component will try your solution as an alternative?

Hi Mostapha,

Yes, I think it is a good idea. I attached a file where you can see the function. It is not perfect yet, but I think its method is very interesting. I think Rhino 5 has some issues with boolean union functions, because sometimes it doesn’t work with some lists of curves or surfaces, but if you try to change the order of elements and then repeating the function, it works.

And this is basically what my function does. However, sometimes it is very slow or it could go to an infinite loop when the solution is almost impossible. For this reason I wrote a limit condition inside the loop.

If you want and you are interested in it, you could work on this method.

Antonello (407 KB)

Hi Antonello,

Thank you for posting the definition. I have two comments.

  1. How does your merge function handles nonplanar shading surfaces? It can happen if the user uses non-planar optionalShdSrf_.

  2. I suggest to update your code to use RhinoCommon. Rhinoscripts can be very slow and is not the best choice for heavy calculations.


Hi Mostapha and Antonello,

As i understand the SHDDesigner doesn’t deal with nonplanar surfaces. The definition says “An optional shade surface representing a 2D area …”. So i assume you are asking about how it works with such planes? So, just tested and it works fine while the original component didn’t.

I am working on an option for nonplanar surfaces and will continue working with Antonello (right?) to get it ready. I suppose we will update the forum at some point if we get things working.


We should fix the input description. ShadingDesigner handles planar and nonplanar surfaces and tries to merge them if needed. Here is an example:

Hmmmmm …

I see. Though for some reason, for all test i do i don’t get the merged surface right. I suppose the key word is “tries” :slight_smile:


Boolean union in Rhino is tricky and doesn’t always work as expected. Can you share once of your cases which fails?


See attached some cases. None of them work as expected.

In addition, one of my double checks is the LB_viewFromSun.


-A. (436 KB)

Hi Abraham

I tested your file, I think the problem in this special cases should be the method of the component, if I understand well, the component projects each shading surfaces using the relative vector onto the optional surface. Then it joins them together, I haven’t read the code of the component but I have imaged something like that.

Hi Mostapha

Is it right, Mostapha?

I have thought another method and maybe it should be easier, obviously we have to see if it true for all cases. These are some images of the result of this alternative method.

P.S. Abraham

Probably, I found an alternative method of the component of pergola shading. I’ll let you know.



Hi Antonello. This looks great and apparently works for all the cases. Well done!

Hi Antonello and Mostapha,

Curious to see the alternative method.

In the meanwhile flipping the normals of the input surfaces worked for some of the cases.

Antonello: I’ll get into you right after this for the pergola …



This is awesome! I always had a sense that this method could be improved. Send a pull request with the new component when you get the chance. Even if it’s written in rhinoscript instead of rhinocommon, a slower component that never fails seems better than a fast component that fails and we can always try to change the rhinoscript over to rhinocommon later. Also, I can re-write that incorrect description once you send the pull request.