mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user