Skip to content
This repository was archived by the owner on Nov 24, 2024. It is now read-only.

Commit 479b937

Browse files
committed
Add a way to load a custom IFC Schema and add util methods
1 parent cada9c9 commit 479b937

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/ifcbimtester/bimtester/features/steps/ifcdata.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
from utils import IfcFile
44

5+
@step('The IFC schema "{schema}" must be provided')
6+
def step_impl(context, schema):
7+
try:
8+
IfcFile.load_schema(schema)
9+
except:
10+
assert False
11+
512

613
@step('The IFC file "{file}" must be provided')
714
def step_impl(context, file):

src/ifcbimtester/bimtester/features/steps/utils.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import ifcopenshell
2+
import ifcopenshell.express
23
import ifcopenshell.util
34
import ifcopenshell.util.element
45

@@ -10,6 +11,13 @@ class IfcFile(object):
1011
@classmethod
1112
def load(cls, path=None):
1213
cls.file = ifcopenshell.open(path)
14+
if not cls.file:
15+
assert False
16+
17+
@classmethod
18+
def load_schema(cls, path=None):
19+
schema = ifcopenshell.express.parse(path)
20+
ifcopenshell.register_schema(schema)
1321

1422
@classmethod
1523
def get(cls):
@@ -23,6 +31,17 @@ def by_guid(cls, guid):
2331
return cls.get().by_guid(guid)
2432
except:
2533
assert False, "An element with the ID {} could not be found.".format(guid)
34+
35+
@classmethod
36+
def by_type(cls, ifc_type):
37+
return cls.get().by_type(ifc_type.strip())
38+
39+
@classmethod
40+
def by_types(cls, ifc_types):
41+
elements = []
42+
for ifc_type in ifc_types.split(","):
43+
elements += cls.by_type(ifc_type.strip())
44+
return elements
2645

2746

2847
def assert_number(number):

0 commit comments

Comments
 (0)