Recognizing Shadows in Dynamo

Hello everyone:

I’m a Master’s student studying how well a set of shading components can prevent unwanted solar radiant heat gain. I’m working on a script for my thesis in which I’m trying to get Dynamo to recognize and report the percentage of a facade’s surface area in shadow. I’m testing how well certain geometries are at blocking solar radiant heat gain, so this is a crucial part of my work.

I’ve modified a bit of code that I discovered on another site which allows me to recognize the shadows cast onto a surface (with a few bugs), but am having trouble figuring out how to report this area as a percentage of total facade area.

This is what the script currently looks like and how it’s performing:
Currently it looks like the family is being projected in front of the facade surface (I don’t understand why this is happening).

And the code starts to break down when I try to determine the perimeter of the shadows.

Could anyone provide assistance with this? It’s somewhat urgent.
Any help would be tremendously appreciated!

Thank you,