From 310738b2ab073ba83a9a88ec14502637c98a29a3 Mon Sep 17 00:00:00 2001 From: Chris Mackey Date: Tue, 9 Jul 2024 17:08:54 -0700 Subject: [PATCH] fix(material): Catch cases of invalid glazing materials --- lib/from_openstudio/material/window_glazing.rb | 7 ++++++- lib/from_openstudio/model.rb | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/from_openstudio/material/window_glazing.rb b/lib/from_openstudio/material/window_glazing.rb index b1e86582..13b741ea 100644 --- a/lib/from_openstudio/material/window_glazing.rb +++ b/lib/from_openstudio/material/window_glazing.rb @@ -45,7 +45,12 @@ def self.from_material(material) hash[:display_name] = (material.displayName.get).force_encoding("UTF-8") end hash[:thickness] = material.thickness - hash[:solar_transmittance] = material.solarTransmittance + # check for the transmittance in begin/rescue in case spectral data is not set + begin + hash[:solar_transmittance] = material.solarTransmittance + rescue + return nil + end # check if boost optional object is empty unless material.frontSideSolarReflectanceatNormalIncidence.empty? hash[:solar_reflectance] = material.frontSideSolarReflectanceatNormalIncidence.get diff --git a/lib/from_openstudio/model.rb b/lib/from_openstudio/model.rb index b27d4a78..3504b1ec 100644 --- a/lib/from_openstudio/model.rb +++ b/lib/from_openstudio/model.rb @@ -194,7 +194,10 @@ def self.materials_from_model(openstudio_model) end # Create HB EnergyWindowMaterialGlazing from OpenStudio Material openstudio_model.getStandardGlazings.each do |material| - result << EnergyWindowMaterialGlazing.from_material(material) + mat_hash = EnergyWindowMaterialGlazing.from_material(material) + unless mat_hash.nil? + result << mat_hash + end end # Create HB EnergyWindowMaterialBlind from OpenStudio Material openstudio_model.getBlinds.each do |material|