Skip to content

Commit

Permalink
feat(door): Allow Shades to be assigned to Doors
Browse files Browse the repository at this point in the history
We recently decided that it was weird that people could not assign shades to Doors but they could to all other geometry objects as noted by [this change in the schema](ladybug-tools/honeybee-schema#24).  This commit updates the measure to support this new feature and I also put the code that creates shade groups into a function so that we have less copy/pasted code.
  • Loading branch information
chriswmackey authored and Chris Mackey committed Jan 27, 2020
1 parent f216876 commit 8fe81e3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 19 deletions.
1 change: 0 additions & 1 deletion lib/from_honeybee/geometry/face.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
require 'from_honeybee/model_object'
require 'from_honeybee/geometry/aperture'
require 'from_honeybee/geometry/door'
require 'from_honeybee/geometry/shade'

require 'openstudio'

Expand Down
55 changes: 37 additions & 18 deletions lib/from_honeybee/geometry/room.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,13 @@ def to_openstudio(openstudio_model)
openstudio_surface = ladybug_face.to_openstudio(openstudio_model)
openstudio_surface.setSpace(os_space)

# TODO: process all air walls between Roooms
# TODO: process all air walls between Rooms

# assign face-level shades if they exist
if face[:outdoor_shades]
os_shd_group = OpenStudio::Model::ShadingSurfaceGroup.new(openstudio_model)
os_shd_group.setShadedSurface(openstudio_surface)
os_shd_group.setSpace(os_space)
os_shd_group.setShadingSurfaceType("Space")
os_shd_group = make_shade_group(openstudio_model, openstudio_surface, os_space)
face[:outdoor_shades].each do |outdoor_shade|
hb_outdoor_shade = Shade.new(outdoor_shade)
os_outdoor_shade = hb_outdoor_shade.to_openstudio(openstudio_model)
os_outdoor_shade.setShadingSurfaceGroup(os_shd_group)
add_shade_to_group(openstudio_model, os_shd_group, outdoor_shade)
end
end

Expand All @@ -123,15 +118,24 @@ def to_openstudio(openstudio_model)
face[:apertures].each do |aperture|
if aperture[:outdoor_shades]
unless os_shd_group
os_shd_group = OpenStudio::Model::ShadingSurfaceGroup.new(openstudio_model)
os_shd_group.setShadedSurface(openstudio_surface)
os_shd_group.setSpace(os_space)
os_shd_group.setShadingSurfaceType("Space")
os_shd_group = make_shade_group(openstudio_model, openstudio_surface, os_space)
end
aperture[:outdoor_shades].each do |outdoor_shade|
hb_outdoor_shade = Shade.new(outdoor_shade)
os_outdoor_shade = hb_outdoor_shade.to_openstudio(openstudio_model)
os_outdoor_shade.setShadingSurfaceGroup(os_shd_group)
add_shade_to_group(openstudio_model, os_shd_group, outdoor_shade)
end
end
end
end

# assign door-level shades if they exist
if face[:doors]
face[:doors].each do |door|
if door[:outdoor_shades]
unless os_shd_group
os_shd_group = make_shade_group(openstudio_model, openstudio_surface, os_space)
end
door[:outdoor_shades].each do |outdoor_shade|
add_shade_to_group(openstudio_model, os_shd_group, outdoor_shade)
end
end
end
Expand All @@ -154,9 +158,7 @@ def to_openstudio(openstudio_model)
os_shd_group.setSpace(os_space)
os_shd_group.setShadingSurfaceType("Space")
@hash[:outdoor_shades].each do |outdoor_shade|
outdoor_shade = Shade.new(outdoor_shade)
os_outdoor_shade = outdoor_shade.to_openstudio(openstudio_model)
os_outdoor_shade.setShadingSurfaceGroup(os_shd_group)
add_shade_to_group(openstudio_model, os_shd_group, outdoor_shade)
end
end

Expand Down Expand Up @@ -255,6 +257,23 @@ def to_openstudio(openstudio_model)

os_space
end

# method to make a space-assigned Shade group for shades assigned to parent objects
def make_shade_group(openstudio_model, openstudio_surface, os_space)
os_shd_group = OpenStudio::Model::ShadingSurfaceGroup.new(openstudio_model)
os_shd_group.setShadedSurface(openstudio_surface)
os_shd_group.setSpace(os_space)
os_shd_group.setShadingSurfaceType("Space")

os_shd_group
end

# method to create a Shade and add it to a shade group
def add_shade_to_group(openstudio_model, os_shd_group, outdoor_shade)
hb_outdoor_shade = Shade.new(outdoor_shade)
os_outdoor_shade = hb_outdoor_shade.to_openstudio(openstudio_model)
os_outdoor_shade.setShadingSurfaceGroup(os_shd_group)
end

# method to check for the closest-assigned interior ceiling or floor construction
def closest_interior_construction(openstudio_model, os_space, surface_type)
Expand Down

0 comments on commit 8fe81e3

Please # to comment.