lib/to_openstudio/geometry/shade.rb in honeybee-openstudio-2.31.8 vs lib/to_openstudio/geometry/shade.rb in honeybee-openstudio-2.31.9

- old
+ new

@@ -59,26 +59,29 @@ os_shading_surface = OpenStudio::Model::ShadingSurface.new(os_vertices, openstudio_model) os_shading_surface.setName(@hash[:identifier]) unless @hash[:display_name].nil? os_shading_surface.setDisplayName(@hash[:display_name]) end - # assign the construction if it exists - if @hash[:properties][:energy][:construction] - construction_identifier = @hash[:properties][:energy][:construction] - construction = openstudio_model.getConstructionByName(construction_identifier) - unless construction.empty? - os_construction = construction.get - os_shading_surface.setConstruction(os_construction) + + if @hash[:properties].key?(:energy) + # assign the construction if it exists + if @hash[:properties][:energy][:construction] + construction_identifier = @hash[:properties][:energy][:construction] + construction = openstudio_model.getConstructionByName(construction_identifier) + unless construction.empty? + os_construction = construction.get + os_shading_surface.setConstruction(os_construction) + end end - end - # assign the transmittance schedule if it exists - if @hash[:properties][:energy][:transmittance_schedule] - schedule_identifier = @hash[:properties][:energy][:transmittance_schedule] - schedule = openstudio_model.getScheduleByName(schedule_identifier) - unless schedule.empty? - os_schedule = schedule.get - os_shading_surface.setTransmittanceSchedule(os_schedule) + # assign the transmittance schedule if it exists + if @hash[:properties][:energy][:transmittance_schedule] + schedule_identifier = @hash[:properties][:energy][:transmittance_schedule] + schedule = openstudio_model.getScheduleByName(schedule_identifier) + unless schedule.empty? + os_schedule = schedule.get + os_shading_surface.setTransmittanceSchedule(os_schedule) + end end end os_shading_surface end