Spaces:
Running
Running
File size: 3,900 Bytes
51982d6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | """
checker_columns β Column compliance checks (IFCore contract).
Checks:
check_column_min_dimension β EHE β smallest cross-section β₯ 250 mm
"""
import sys
import ifcopenshell
import ifcopenshell.util.element
# ββ Private helpers ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def _get_pset_value(elem, pset_name, prop_name):
try:
psets = ifcopenshell.util.element.get_psets(elem)
if pset_name in psets and prop_name in psets[pset_name]:
v = psets[pset_name][prop_name]
if v is not None and v != "":
return v
except Exception:
pass
return None
def _to_mm(value):
if value is None:
return None
return round(value) if value > 100 else round(value * 1000)
# ββ Check functions (IFCore contract) βββββββββββββββββββββββββββββββββββββββββ
def check_column_min_dimension(model, min_dim_mm=250):
"""EHE β smallest cross-section side of a column β₯ 250 mm."""
results = []
for col in model.by_type("IfcColumn"):
name = col.Name or f"IfcColumn #{col.id()}"
w = (
_get_pset_value(col, "PSet_Revit_Type_Dimensions", "b")
or _get_pset_value(col, "PSet_Revit_Type_Dimensions", "bf")
or _get_pset_value(col, "Qto_ColumnBaseQuantities", "Width")
)
d = (
_get_pset_value(col, "PSet_Revit_Type_Dimensions", "d")
or _get_pset_value(col, "PSet_Revit_Type_Dimensions", "h")
or _get_pset_value(col, "Qto_ColumnBaseQuantities", "Depth")
)
smallest = None
if w is not None and d is not None:
smallest = min(_to_mm(w), _to_mm(d))
elif w is not None:
smallest = _to_mm(w)
elif d is not None:
smallest = _to_mm(d)
if smallest is not None:
status = "pass" if smallest >= min_dim_mm else "fail"
comment = (f"EHE satisfied: {smallest} mm β₯ {min_dim_mm} mm"
if status == "pass"
else f"Column too narrow: {smallest} mm < minimum {min_dim_mm} mm")
actual = f"{smallest} mm"
else:
status = "blocked"
comment = "Dimensions not found in PSet_Revit_Type_Dimensions or Qto_ColumnBaseQuantities"
actual = None
results.append({
"element_id": col.GlobalId,
"element_type": "IfcColumn",
"element_name": name,
"element_name_long": f"{name} β EHE Column Min Dimension",
"check_status": status,
"actual_value": actual,
"required_value": f"β₯ {min_dim_mm} mm",
"comment": comment,
"log": None,
})
return results
if __name__ == "__main__":
ifc_path = sys.argv[1] if len(sys.argv) > 1 else "data/01_Duplex_Apartment.ifc"
print("Loading:", ifc_path)
_model = ifcopenshell.open(ifc_path)
print("Columns:", len(list(_model.by_type("IfcColumn"))))
_ICON = {"pass": "PASS", "fail": "FAIL", "warning": "WARN", "blocked": "BLKD", "log": "LOG "}
for _fn in [check_column_min_dimension]:
print("\n" + "=" * 60)
print(" ", _fn.__name__)
print("=" * 60)
for _row in _fn(_model):
print(" ", "[" + _ICON.get(_row["check_status"], "?") + "]", _row["element_name"])
if _row["actual_value"]:
print(" actual :", _row["actual_value"])
if _row["required_value"]:
print(" required :", _row["required_value"])
print(" comment :", _row["comment"])
|