Skip to content

Commit 72cfcd3

Browse files
committed
Completes holds construction test
1 parent 7c121cc commit 72cfcd3

File tree

3 files changed

+13520
-2
lines changed

3 files changed

+13520
-2
lines changed

src/osut/osut.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,80 @@ def genMass(sps=None, ratio=2.0) -> bool:
979979
return True
980980

981981

982+
def holdsConstruction(set=None, bse=None, gr=False, ex=False, tp=""):
983+
"""Validates whether a default construction set holds an opaque base
984+
construction.
985+
986+
Args:
987+
set (openstudio.model.DefaultConstructionSet):
988+
A default construction set.
989+
bse (openstudio.model.ConstructionBase):
990+
A construction base.
991+
gr (bool):
992+
Whether ground-facing surface.
993+
ex (bool):
994+
Whether exterior-facing surface.
995+
tp:
996+
A surface type ("Wall", "Floor", "RoofCeiling").
997+
998+
Returns:
999+
bool: Whether default set holds construction.
1000+
False: If invalid input (see logs).
1001+
1002+
"""
1003+
mth = "osut.holdsConstruction"
1004+
cl1 = openstudio.model.DefaultConstructionSet
1005+
cl2 = openstudio.model.ConstructionBase
1006+
1007+
if not isinstance(set, cl1):
1008+
return oslg.invalid("set" , mth, 1, CN.DBG, False)
1009+
if not isinstance(bse, cl2):
1010+
return oslg.invalid("base", mth, 2, CN.DBG, False)
1011+
if gr not in [True, False]:
1012+
return oslg.invalid("ground", mth, 3, CN.DBG, False)
1013+
if ex not in [True, False]:
1014+
return oslg.invalid("exterior", mth, 4, CN.DBG, False)
1015+
1016+
try:
1017+
tp = str(tp)
1018+
except ValueError as e:
1019+
return oslg.mismatch("surface type", tp, str, mth, CN.DBG, False)
1020+
1021+
type = tp.lower()
1022+
1023+
if tp not in ["floor", "wall", "roofceiling"]:
1024+
return oslg.invalid("surface type", mth, 5, CN.DBG, False)
1025+
1026+
constructions = None
1027+
1028+
if gr:
1029+
if set.defaultGroundContactSurfaceConstructions():
1030+
constructions = set.defaultGroundContactSurfaceConstructions().get()
1031+
elif ex:
1032+
if set.defaultExteriorSurfaceConstructions():
1033+
constructions = set.defaultExteriorSurfaceConstructions().get()
1034+
else:
1035+
if set.defaultInteriorSurfaceConstructions():
1036+
constructions = set.defaultInteriorSurfaceConstructions().get()
1037+
1038+
if not constructions: return False
1039+
1040+
if type == "roofceiling":
1041+
if constructions.roofCeilingConstruction():
1042+
construction = constructions.roofCeilingConstruction().get()
1043+
if construction == bse: return True
1044+
elif type == "floor":
1045+
if constructions.floorConstruction():
1046+
construction = constructions.floorConstruction().get()
1047+
if construction == bse: return True
1048+
else:
1049+
if constructions.wallConstruction():
1050+
construction = constructions.wallConstruction().get()
1051+
if construction == bse: return True
1052+
1053+
return False
1054+
1055+
9821056
def transforms(group=None) -> dict:
9831057
""""Returns OpenStudio site/space transformation & rotation angle.
9841058

0 commit comments

Comments
 (0)