Question-and-Answer Resource for the Building Energy Modeling Community
Get s tarted with the Help page
Ask Your Question

Add rooftop PV azimuth

asked 2018-02-13 04:23:16 -0600

updated 2018-02-13 13:06:28 -0600

I'd like to adapt the add rooftop pv measure to only apply to roof surfaces which face south, or say within 180 degrees of south. Looking at the measure it looks like this functionality was originally intended but not completed. I'm new to measure writing and Ruby, in the measure it looks like the following term gets the surfaces:

 model.getSurfaces.each do |surface|
  next if not
  if surface.surfaceType == "RoofCeiling" and surface.outsideBoundaryCondition == "Outdoors"

How would I include azimuth within this? Also to deal with flat roofs would it be possible to have an or function whereby all flat roofs would also be included?

Any advice appreciated.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2018-02-13 21:46:38 -0600

updated 2018-02-14 03:35:14 -0600

If you know that neither the space or the building are rotated to a non 0 value then you can get the azimuth in degrees of a surface using OpenStudio::convert(surface.azimuth,"rad","deg").get but the code below, which is from the Window to Wall Ratio gives absolute azimuth including space and building rotation. You could change the test for south to 90 to 270

  # get the absoluteAzimuth for the surface so we can categorize it
  absoluteAzimuth =  OpenStudio::convert(s.azimuth,"rad","deg").get + + model.getBuilding.northAxis
  until absoluteAzimuth < 360.0
    absoluteAzimuth = absoluteAzimuth - 360.0

  if facade == "North"
    next if not (absoluteAzimuth >= 315.0 or absoluteAzimuth < 45.0)
  elsif facade == "East"
    next if not (absoluteAzimuth >= 45.0 and absoluteAzimuth < 135.0)
  elsif facade == "South"
    next if not (absoluteAzimuth >= 135.0 and absoluteAzimuth < 225.0)
  elsif facade == "West"
    next if not (absoluteAzimuth >= 225.0 and absoluteAzimuth < 315.0)
    runner.registerError("Unexpected value of facade: " + facade + ".")
    return false

You could also include or exclude horizontal surfaces using surface.tiltbut you may want to put in a small tolerance as shown here in the SketchUp Plugin surface search. As you might expect the azimuth returned isn't very reliable on horizontal surfaces, what is returned might related order of vertices.

Specific to adapting the Rooftop PV measure with non horizontal surfaces, I believe the measure increases the z value for all vertices to 'offset' the pv shading surface vertically above the roof, so with a heavily tilted roof, this may not be what you want. There may be a nice method to offset a surface within its current plane, but I have not done that before.

edit flag offensive delete link more


Thanks David for your fast and helpful response. I will give that a try.

josh.sykes gravatar image josh.sykes  ( 2018-02-14 03:33:02 -0600 )edit

answered 2018-02-14 09:49:33 -0600

updated 2018-02-14 10:04:36 -0600

To project the PV (or whatever) surface along a base surface normal regardless of the surface's tilt/orientation (which is How It Should Be Done), do something like this:

  # get the base surface normal (vector)
  vec = surface.outwardNormal
  vec.setLength(0.0254) # PV/shading/whatever surface projection (m)

  # get window points and project along window normal
  vertices = surface.vertices
  transform =
  transform = if

  # transform to world coords
  vertices = transform * vertices

  points = []
  vertices.each do |f|
    pp = f + vec
    points << pp

  points = transform.inverse * points # send back to space coords

  # Make the new PV/shading/whatever surface
  shading_surface =, model)
edit flag offensive delete link more


Thanks for your response, I really need to include the surface orientation as I'm using the measure as part of an automation process. Still struggling to get it to work though.

josh.sykes gravatar image josh.sykes  ( 2018-02-19 14:04:00 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer


Question Tools



Asked: 2018-02-13 04:23:16 -0600

Seen: 159 times

Last updated: Feb 14 '18