[B1][18] IFC-Export gegen ifcopenshell pruefen (Schema, Express-Regeln, Geometrie je Bauteil); Fund behoben: IfcOwnerHistory ADDED ohne LastModifiedDate

- scripts/validate-ifc.py (eigenes Pruefskript), exportIfc.validate.test.ts ruft es auf, wenn ifcopenshell
  installiert ist (sonst uebersprungen); CI installiert ifcopenshell + pytest

Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
Claude committed 2026-10-27 20:29:53 +00:00
1 parent 301f488653
commit 2c43190ae0
4 files changed
+84 -1

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
"""IFC-Datei prüfen ([B1]/[18]): Schema + Express-Regeln (ifcopenshell.validate) und Geometrie je Bauteil.
Aufruf: python3 scripts/validate-ifc.py datei.ifc [weitere.ifc …]
Exit 0 = alles gültig; sonst werden die Befunde ausgegeben und Exit 1.
Braucht `pip install ifcopenshell` (getestet mit 0.8/0.9).
"""
import sys
import ifcopenshell
import ifcopenshell.geom
import ifcopenshell.validate
def check(path: str) -> int:
logger = ifcopenshell.validate.json_logger()
model = ifcopenshell.open(path)
ifcopenshell.validate.validate(model, logger, express_rules=True)
problems = [f"{s.get('level', '?')}: {s.get('message', s)}" for s in logger.statements]
settings = ifcopenshell.geom.settings()
shapes = 0
for product in model.by_type("IfcProduct"):
if product.Representation is None:
continue
try:
ifcopenshell.geom.create_shape(settings, product)
shapes += 1
except Exception as exc: # noqa: BLE001 — jeder Geometriefehler ist ein Befund
problems.append(f"Geometrie {product.is_a()} #{product.id()} {product.Name!r}: {exc}")
print(f"{path}: {len(model.by_type('IfcProduct'))} Produkte, {shapes} Körper, {len(problems)} Befunde")
for p in problems[:200]:
print(" " + p)
return 1 if problems else 0
if __name__ == "__main__":
if len(sys.argv) < 2:
print(__doc__)
sys.exit(2)
sys.exit(max(check(p) for p in sys.argv[1:]))