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

Revision history [back]

@antonszilasi that looks good, but if you are not filtering by spaces at all, then you can just loop through sub_surfaces directly, and then just set the constructions within the elsif statements.

model.getSubSurfaces.each do |sub_surface|
  # only alter exterior windows.
  next if sub_surface.surfaceType != 'Wall'
  next if sub_surface.outsideBoundaryCondition != 'Outdoors'

  # store absoluteAzimuth
  absoluteAzimuth = OpenStudio.convert(sub_surface.azimuth, 'rad', 'deg').get + sub_surface.space.get.directionofRelativeNorth + model.getBuilding.northAxis
  absoluteAzimuth -= 360.0 until absoluteAzimuth < 360.0

  # check orientation and assign construction
  if (options['northEast'] <= absoluteAzimuth) && (absoluteAzimuth < options['southEast']) # East exterior walls
    sub_surface.setConstruction(WindowTypeEast)
  elsif (options['southEast'] <= absoluteAzimuth) && (absoluteAzimuth < options['southWest']) # South exterior walls
    sub_surface.setConstruction(WindowTypeSouth)
  elsif (options['southWest'] <= absoluteAzimuth) && (absoluteAzimuth < options['northWest']) # West exterior walls
    sub_surface.setConstruction(WindowTypeWest)
  else # North exterior walls
    sub_surface.setConstruction(WindowTypeNorth)
  end
end

@antonszilasi that looks good, but if you are not filtering by spaces at all, then you can just loop through sub_surfaces directly, and then just set the constructions within the elsif statements.

model.getSubSurfaces.each do |sub_surface|
  # only alter exterior windows.
  next if sub_surface.surfaceType sub_surface.subSurfaceType != 'Wall'
'FixedWindow'
  next if sub_surface.outsideBoundaryCondition != 'Outdoors'

  # store absoluteAzimuth
  absoluteAzimuth = OpenStudio.convert(sub_surface.azimuth, 'rad', 'deg').get + sub_surface.space.get.directionofRelativeNorth + model.getBuilding.northAxis
  absoluteAzimuth -= 360.0 until absoluteAzimuth < 360.0

  # check orientation and assign construction
  if (options['northEast'] <= absoluteAzimuth) && (absoluteAzimuth < options['southEast']) # East exterior walls
    sub_surface.setConstruction(WindowTypeEast)
  elsif (options['southEast'] <= absoluteAzimuth) && (absoluteAzimuth < options['southWest']) # South exterior walls
    sub_surface.setConstruction(WindowTypeSouth)
  elsif (options['southWest'] <= absoluteAzimuth) && (absoluteAzimuth < options['northWest']) # West exterior walls
    sub_surface.setConstruction(WindowTypeWest)
  else # North exterior walls
    sub_surface.setConstruction(WindowTypeNorth)
  end
end