Aligning normals across a variety of surfaces

I’m trying to create a script that array photovoltaics across any set of planar surfaces one might want. I’m running into an issue where depending on how you draw the surface, the surface normal is either positive or negative, which affects the direction the panels tilt in. Though one could redraw the surface, I’d prefer the script to be agnostic of input.
I’ve tried to modify the script so that it sorts surface by normal direction and flips those that are outliers, but I’ve had trouble getting this to ‘stick’–i.e. the surface will revert to it’s native normal after running through another component. Putting my ‘normal correcting script’ at the end doesn’t help either.
Could anyone shed some light on what I’m missing? (28.2 KB)

Well, well, hello again. This has been on my mind since your other thread yesterday:

The first thing I did was flip all the roof surfaces so their normals point up, using Flip with a PlaneSrf as a guide. But I didn’t stop there. :sunglasses: (40.1 KB)

I see you are still using Pufferfish for Rotate Plane XYZ ? :man_facepalming:


P.S. Here is your new set of roof surfaces:

You didn’t answer my questions yesterday:

Parallel to one edge of the roof? Bottom edge? Top edge? How does this work on roof surfaces that face north?

This might be interesting? Top view is at the bottom, perspective view above it. Vectors are exaggerated (times 80) to see them better.


Only two of the five roof surfaces have normal vectors facing south (-Y), red and blue, both with a slight eastward component. Green and pink have a slight north component (+Y) but are predominantly east (green, +X) or west (pink, -X). The yellow surface faces north east.

Solar gain always starts with architecture. By area, this roof faces more north (+Y) than south.

Joseph, old friend–thanks for taking a look at my mess once again. Yesterday I did try to create the rotation I was looking for without pufferfish and got stumped. Today is obviously a new day, because I figured it out very quickly! I’ve attached the new file so you can view the final desired result.

The panels should face south (-y) regardless of the roof geometry. Of course any sensible designer would first create logical roof geo before applying PV (no north faces etc), but I am for now trying to create a durable script that can be applied to any combination of planar geometry. These faces are just a random collection I sketched to demonstrate the issue with the effect of face normals on rotation direction. With or without pufferfish, the face with the normal that is positive while the rest are negative rotates up in the opposite direction. This behavior is made obvious when I simply flip the panel in Rhino–the panels now face the ‘correct’ direction.

Thanks also for that final little script. Quite neat and super smart. Would actually be good to include to help guide a user into selecting only surfaces with ideal exposures to apply panels to.

Also, the output is planes and not extrusions because I’m plugging this into a radiation analysis engine that requires surfaces as an input.

Updated: (27.7 KB)

Have we met before? Or was it only 18 hours ago?

I didn’t look at your code until after I had written and posted mine yesterday.

Your code today doesn’t have the roof surfaces internalized so I copied them from yesterday’s code with my solution for flipping all their normals up. Looks like your rotation is still messed up somewhere but I don’t have time to dig into it, I need to take a break. Back in less than an hour:

Oh, how long 18 hours can seem; (no, I’ve simply read many of your previous solutions)

File has been updated.

No rush, I have to pull my head out of the grasshopper hole for a bit too, but I will try again later. I still suspect it’s something small, but time will tell…

It appears that you aren’t taking any of my advice.

  • You are flipping surface normals the hard way (twice?) instead of using a guide surface,
  • You don’t have a plane for each rectangle but instead are using Orient repeatedly (four times where I don’t use it at all). Apparently you are deriving planes from the oriented rectangles?
  • I am dubious about north facing surfaces and rotating panels, which it looks like you haven’t got right yet. It’s obviously more difficult to install panels on rotated racks at different angles for each surface than putting them flat on the roof.
  • I have 3036 panels, you have 1773 on the same roof.

I have slightly different priorities I think.

  • The panels need to be able to be tilted upwards, not planar to the roof surface. The tilt needs to occur at the level of each row, and the rows need to be spaced out once they are tilted to avoid self-shading, hence the lower panel density.
  • The panels should not necessarily be aligned in columns, as this reduces the total number of panels for little gain; (installation occurs in rows with no necessary link b/t each row).
  • The panels also need to rotate as a unit on the entire roof surface, in case a model they are inserted into does not have south set as -y.
  • The north facing surfaces are merely a test, as is all of this geometry.

The script you attached is great but it would require some re-working to integrate all of these parameters, rather than fixing the one issue of aligning the normals in my script. I’m sure there are many ways of doing this same task more elegantly and with fewer ‘orient’ modules, but it works well enough right now and isn’t too slow. Perhaps this one fix is actually many, and I will eat my words! But I will try a little bit more for now.
Thanks for taking a look at this again, I appreciate the time.