BuildingSmart IFCRail changes to BIMTester (#1309)

* Add a way to validate the IFC file in BIMTester

* Fix an issue in Report where only the first error was shown

* Fix the usage of Schema in BIMTester

* Add Aggreation steps to BIMTester
This commit is contained in:
rbertucat
2021-02-11 23:34:10 +01:00
committed by GitHub
parent 1d6b2dcb37
commit 20fe48bd6a
8 changed files with 260 additions and 16 deletions
+21
View File
@@ -1,8 +1,29 @@
import ifcopenshell
import ifcopenshell.util.element
import ifcopenshell.validate
import json
from bimtester.lang import _
def by_types(ifc, ifc_types):
elements = []
for ifc_type in ifc_types.split(","):
elements += ifc.by_type(ifc_type.strip())
return elements
def validate(ifc):
errors = []
logger = ifcopenshell.validate.json_logger()
try:
ifcopenshell.validate.validate(ifc, logger)
if logger.statements:
for statement in logger.statements:
errors.append(f"{json.dumps(statement, default=str)}")
except RuntimeError as error:
assert False, str(error)
def assert_guid(ifc, guid):
try:
return ifc.by_guid(guid)