mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 18:21:59 +00:00
More IDS test structuring and add support for checking logical unknown
This commit is contained in:
@@ -618,6 +618,7 @@ class attribute(facet):
|
|||||||
if isinstance(self.name, str):
|
if isinstance(self.name, str):
|
||||||
type_value = getattr(element_type, self.name, None) if element_type else None
|
type_value = getattr(element_type, self.name, None) if element_type else None
|
||||||
occurrence_value = getattr(inst, self.name, None)
|
occurrence_value = getattr(inst, self.name, None)
|
||||||
|
names = [self.name]
|
||||||
values = [occurrence_value if occurrence_value is not None else type_value]
|
values = [occurrence_value if occurrence_value is not None else type_value]
|
||||||
else:
|
else:
|
||||||
if element_type:
|
if element_type:
|
||||||
@@ -625,9 +626,31 @@ class attribute(facet):
|
|||||||
info.update({k: v for k, v in inst.get_info().items() if v is not None})
|
info.update({k: v for k, v in inst.get_info().items() if v is not None})
|
||||||
else:
|
else:
|
||||||
info = inst.get_info()
|
info = inst.get_info()
|
||||||
values = [v for k, v in info.items() if k == self.name]
|
names = []
|
||||||
|
values = []
|
||||||
|
for k, v in info.items():
|
||||||
|
if k == self.name:
|
||||||
|
names.append(k)
|
||||||
|
values.append(v)
|
||||||
|
|
||||||
|
is_pass = bool(values)
|
||||||
|
|
||||||
|
if is_pass:
|
||||||
|
for i, value in enumerate(values):
|
||||||
|
if value is None:
|
||||||
|
is_pass = False
|
||||||
|
elif value == "":
|
||||||
|
is_pass = False
|
||||||
|
elif value == tuple():
|
||||||
|
is_pass = False
|
||||||
|
elif (
|
||||||
|
inst.attribute_type(inst.wrapped_data.get_argument_index(names[i])) == "LOGICAL"
|
||||||
|
and value == "UNKNOWN"
|
||||||
|
):
|
||||||
|
is_pass = False
|
||||||
|
if not is_pass:
|
||||||
|
break
|
||||||
|
|
||||||
is_pass = bool(values) and all([v is not None and v != "" for v in values])
|
|
||||||
if is_pass and self.value:
|
if is_pass and self.value:
|
||||||
is_pass = all([v == self.value for v in values])
|
is_pass = all([v == self.value for v in values])
|
||||||
|
|
||||||
|
|||||||
@@ -28,14 +28,17 @@ from ifcopenshell import ids, template, validate
|
|||||||
|
|
||||||
outdir = "build"
|
outdir = "build"
|
||||||
|
|
||||||
class spec_generator:
|
|
||||||
cases = []
|
class DocGenerator:
|
||||||
|
def __init__(self):
|
||||||
|
self.facet = None
|
||||||
|
self.testcases = {}
|
||||||
|
|
||||||
def __call__(self, name, *, facet, inst, expected):
|
def __call__(self, name, *, facet, inst, expected):
|
||||||
if not name:
|
if not name:
|
||||||
return
|
return
|
||||||
|
|
||||||
fail_or_pass = "pass" if expected is True else "fail"
|
result = "pass" if expected is True else "fail"
|
||||||
|
|
||||||
# Create an IFC file with the instance in `inst` passed to us
|
# Create an IFC file with the instance in `inst` passed to us
|
||||||
# based on an IFC file template with project and units.
|
# based on an IFC file template with project and units.
|
||||||
@@ -61,11 +64,11 @@ class spec_generator:
|
|||||||
else:
|
else:
|
||||||
raise Exception("About to emit invalid example data")
|
raise Exception("About to emit invalid example data")
|
||||||
|
|
||||||
ifc_text = "\n".join(
|
ifc_lines = list(map(str, {i: None for i in itertools.chain.from_iterable(map(f.traverse, instances))}.keys()))
|
||||||
map(str, {inst: None for inst in itertools.chain.from_iterable(map(f.traverse, instances))}.keys())
|
ifc_id = ifc_lines[0].split("=")[0]
|
||||||
)
|
ifc_text = "\n".join(ifc_lines)
|
||||||
|
|
||||||
basename = f"{fail_or_pass}-" + re.sub("[^0-9a-zA-Z]", "_", name.lower())
|
basename = f"{result}-" + re.sub("[^0-9a-zA-Z]", "_", name.lower())
|
||||||
|
|
||||||
# Write IFC to disk
|
# Write IFC to disk
|
||||||
f.write(os.path.join(outdir, f"{basename}.ifc"))
|
f.write(os.path.join(outdir, f"{basename}.ifc"))
|
||||||
@@ -92,30 +95,39 @@ class spec_generator:
|
|||||||
if l.strip()
|
if l.strip()
|
||||||
).replace("\t", " ")
|
).replace("\t", " ")
|
||||||
|
|
||||||
self.cases.append({
|
self.testcases.setdefault(self.facet, []).append(
|
||||||
"name": name, "ids": xml_text, "ifc": ifc_text, "basename": basename, "result": fail_or_pass
|
{"name": name, "ids": xml_text, "ifc": ifc_text, "basename": basename, "result": result, "id": ifc_id}
|
||||||
})
|
)
|
||||||
|
|
||||||
assert bool(facet(inst)) is expected
|
assert bool(facet(inst)) is expected
|
||||||
|
|
||||||
|
def set_facet(self, facet):
|
||||||
|
self.facet = facet
|
||||||
|
|
||||||
test_ids.case = spec_generator()
|
|
||||||
|
|
||||||
suite = unittest.TestLoader().discover('.', pattern='test_ids.py')
|
test_ids.run = DocGenerator()
|
||||||
|
test_ids.set_facet = test_ids.run.set_facet
|
||||||
|
|
||||||
|
suite = unittest.TestLoader().discover(".", pattern="test_ids.py")
|
||||||
result = unittest.TextTestRunner(verbosity=2).run(suite)
|
result = unittest.TextTestRunner(verbosity=2).run(suite)
|
||||||
|
|
||||||
with open(os.path.join(outdir, "spec.md"), "w") as f:
|
for facet, testcases in test_ids.run.testcases.items():
|
||||||
for c in test_ids.case.cases:
|
with open(os.path.join(outdir, f"testcases-{facet}.md"), "w") as f:
|
||||||
write = functools.partial(print, file=f)
|
write = functools.partial(print, file=f)
|
||||||
write(f"## [{c['result'].upper()}] {c['name']}")
|
write(f"# {facet.capitalize()} testcases")
|
||||||
write()
|
write()
|
||||||
write("~~~xml")
|
write("These testcases are designed to help describe behaviour in edge cases and ambiguities. All valid IDS implementations must demonstrate identical behaviour to these test cases.")
|
||||||
write(c['ids'])
|
|
||||||
write("~~~")
|
|
||||||
write()
|
|
||||||
write("~~~lua")
|
|
||||||
write(c['ifc'])
|
|
||||||
write("~~~")
|
|
||||||
write()
|
|
||||||
write(f"[Sample IDS]({c['basename']}.ids) - [Sample IFC]({c['basename']}.ifc)")
|
|
||||||
write()
|
write()
|
||||||
|
for testcase in testcases:
|
||||||
|
write(f"## [{testcase['result'].upper()}] {testcase['name']}")
|
||||||
|
write()
|
||||||
|
write("~~~xml")
|
||||||
|
write(testcase["ids"])
|
||||||
|
write("~~~")
|
||||||
|
write()
|
||||||
|
write("~~~lua")
|
||||||
|
write(testcase["ifc"])
|
||||||
|
write("~~~")
|
||||||
|
write()
|
||||||
|
write(f"[Sample IDS]({testcase['basename']}.ids) - [Sample IFC: {testcase['id']}]({testcase['basename']}.ifc)")
|
||||||
|
write()
|
||||||
|
|||||||
@@ -41,7 +41,10 @@ ifc_file = ifcopenshell.open(IFC_URL)
|
|||||||
os.remove(os.path.join(tempfile.gettempdir(), "test.ifc"))
|
os.remove(os.path.join(tempfile.gettempdir(), "test.ifc"))
|
||||||
|
|
||||||
|
|
||||||
def case(name, *, facet, inst, expected):
|
def set_facet(facet):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def run(name, *, facet, inst, expected):
|
||||||
assert bool(facet(inst)) is expected
|
assert bool(facet(inst)) is expected
|
||||||
|
|
||||||
|
|
||||||
@@ -257,20 +260,22 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def test_filtering_using_an_entity_facet(self):
|
def test_filtering_using_an_entity_facet(self):
|
||||||
|
set_facet("entity")
|
||||||
|
|
||||||
ifc = ifcopenshell.file()
|
ifc = ifcopenshell.file()
|
||||||
|
|
||||||
facet = ids.entity.create(name="IFCRABBIT")
|
facet = ids.entity.create(name="IFCRABBIT")
|
||||||
case("Invalid entities always fail", facet=facet, inst=ifc.createIfcWall(), expected=False)
|
run("Invalid entities always fail", facet=facet, inst=ifc.createIfcWall(), expected=False)
|
||||||
|
|
||||||
facet = ids.entity.create(name="IFCWALL")
|
facet = ids.entity.create(name="IFCWALL")
|
||||||
case("A matching entity should pass", facet=facet, inst=ifc.createIfcWall(), expected=True)
|
run("A matching entity should pass", facet=facet, inst=ifc.createIfcWall(), expected=True)
|
||||||
case(
|
run(
|
||||||
"An matching entity should pass regardless of predefined type",
|
"An matching entity should pass regardless of predefined type",
|
||||||
facet=facet,
|
facet=facet,
|
||||||
inst=ifc.createIfcWall(PredefinedType="SOLIDWALL"),
|
inst=ifc.createIfcWall(PredefinedType="SOLIDWALL"),
|
||||||
expected=True,
|
expected=True,
|
||||||
)
|
)
|
||||||
case(
|
run(
|
||||||
"An entity not matching the specified class should fail",
|
"An entity not matching the specified class should fail",
|
||||||
facet=facet,
|
facet=facet,
|
||||||
inst=ifc.createIfcSlab(),
|
inst=ifc.createIfcSlab(),
|
||||||
@@ -278,7 +283,7 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
# TODO: Some votes to prefer inheritance (For: Moult, Evandro, Artur)
|
# TODO: Some votes to prefer inheritance (For: Moult, Evandro, Artur)
|
||||||
# Possible argument: CAD tools don't understand IFC
|
# Possible argument: CAD tools don't understand IFC
|
||||||
case(
|
run(
|
||||||
"Subclasses are not considered as matching",
|
"Subclasses are not considered as matching",
|
||||||
facet=facet,
|
facet=facet,
|
||||||
inst=ifc.createIfcWallStandardCase(),
|
inst=ifc.createIfcWallStandardCase(),
|
||||||
@@ -287,7 +292,7 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
|
|
||||||
# TODO But in that case why are the enumerations for things like partOf using the IFC capitalisation?
|
# TODO But in that case why are the enumerations for things like partOf using the IFC capitalisation?
|
||||||
facet = ids.entity.create(name="IfcWall")
|
facet = ids.entity.create(name="IfcWall")
|
||||||
case(
|
run(
|
||||||
"Entities must be specified as uppercase strings",
|
"Entities must be specified as uppercase strings",
|
||||||
facet=facet,
|
facet=facet,
|
||||||
inst=ifc.createIfcWall(),
|
inst=ifc.createIfcWall(),
|
||||||
@@ -295,19 +300,19 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
facet = ids.entity.create(name="IFCWALL", predefinedType="SOLIDWALL")
|
facet = ids.entity.create(name="IFCWALL", predefinedType="SOLIDWALL")
|
||||||
case(
|
run(
|
||||||
"A matching predefined type should pass",
|
"A matching predefined type should pass",
|
||||||
facet=facet,
|
facet=facet,
|
||||||
inst=ifc.createIfcWall(PredefinedType="SOLIDWALL"),
|
inst=ifc.createIfcWall(PredefinedType="SOLIDWALL"),
|
||||||
expected=True,
|
expected=True,
|
||||||
)
|
)
|
||||||
case(
|
run(
|
||||||
"A null predefined type should always fail a specified predefined types",
|
"A null predefined type should always fail a specified predefined types",
|
||||||
facet=facet,
|
facet=facet,
|
||||||
inst=ifc.createIfcWall(),
|
inst=ifc.createIfcWall(),
|
||||||
expected=False,
|
expected=False,
|
||||||
)
|
)
|
||||||
case(
|
run(
|
||||||
"An entity not matching a specified predefined type will fail",
|
"An entity not matching a specified predefined type will fail",
|
||||||
facet=facet,
|
facet=facet,
|
||||||
inst=ifc.createIfcWall(PredefinedType="PARTITIONING"),
|
inst=ifc.createIfcWall(PredefinedType="PARTITIONING"),
|
||||||
@@ -315,7 +320,7 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
facet = ids.entity.create(name="IFCWALL", predefinedType="solidwall")
|
facet = ids.entity.create(name="IFCWALL", predefinedType="solidwall")
|
||||||
case(
|
run(
|
||||||
"A predefined type from an enumeration must be uppercase",
|
"A predefined type from an enumeration must be uppercase",
|
||||||
facet=facet,
|
facet=facet,
|
||||||
inst=ifc.createIfcWall(PredefinedType="SOLIDWALL"),
|
inst=ifc.createIfcWall(PredefinedType="SOLIDWALL"),
|
||||||
@@ -323,7 +328,7 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
facet = ids.entity.create(name="IFCWALL", predefinedType="WALDO")
|
facet = ids.entity.create(name="IFCWALL", predefinedType="WALDO")
|
||||||
case(
|
run(
|
||||||
"A predefined type may specify a user-defined object type",
|
"A predefined type may specify a user-defined object type",
|
||||||
facet=facet,
|
facet=facet,
|
||||||
inst=ifc.createIfcWall(PredefinedType="USERDEFINED", ObjectType="WALDO"),
|
inst=ifc.createIfcWall(PredefinedType="USERDEFINED", ObjectType="WALDO"),
|
||||||
@@ -331,7 +336,7 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
facet = ids.entity.create(name="IFCWALL", predefinedType="WALDO")
|
facet = ids.entity.create(name="IFCWALL", predefinedType="WALDO")
|
||||||
case(
|
run(
|
||||||
"User-defined types are checked case sensitively",
|
"User-defined types are checked case sensitively",
|
||||||
facet=facet,
|
facet=facet,
|
||||||
inst=ifc.createIfcWall(PredefinedType="USERDEFINED", ObjectType="waldo"),
|
inst=ifc.createIfcWall(PredefinedType="USERDEFINED", ObjectType="waldo"),
|
||||||
@@ -339,7 +344,7 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
facet = ids.entity.create(name="IFCWALLTYPE", predefinedType="WALDO")
|
facet = ids.entity.create(name="IFCWALLTYPE", predefinedType="WALDO")
|
||||||
case(
|
run(
|
||||||
"A predefined type may specify a user-defined element type",
|
"A predefined type may specify a user-defined element type",
|
||||||
facet=facet,
|
facet=facet,
|
||||||
inst=ifc.createIfcWallType(PredefinedType="USERDEFINED", ElementType="WALDO"),
|
inst=ifc.createIfcWallType(PredefinedType="USERDEFINED", ElementType="WALDO"),
|
||||||
@@ -347,7 +352,7 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
facet = ids.entity.create(name="IFCTASKTYPE", predefinedType="TASKY")
|
facet = ids.entity.create(name="IFCTASKTYPE", predefinedType="TASKY")
|
||||||
case(
|
run(
|
||||||
"A predefined type may specify a user-defined process type",
|
"A predefined type may specify a user-defined process type",
|
||||||
facet=facet,
|
facet=facet,
|
||||||
inst=ifc.createIfcTaskType(PredefinedType="USERDEFINED", ProcessType="TASKY"),
|
inst=ifc.createIfcTaskType(PredefinedType="USERDEFINED", ProcessType="TASKY"),
|
||||||
@@ -355,7 +360,7 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
facet = ids.entity.create(name="IFCWALL", predefinedType="USERDEFINED")
|
facet = ids.entity.create(name="IFCWALL", predefinedType="USERDEFINED")
|
||||||
case(
|
run(
|
||||||
"A predefined type must always specify a meaningful type, not USERDEFINED itself",
|
"A predefined type must always specify a meaningful type, not USERDEFINED itself",
|
||||||
facet=facet,
|
facet=facet,
|
||||||
inst=ifc.createIfcWall(PredefinedType="USERDEFINED", ObjectType="WALDO"),
|
inst=ifc.createIfcWall(PredefinedType="USERDEFINED", ObjectType="WALDO"),
|
||||||
@@ -366,7 +371,7 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
wall_type = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWallType", predefined_type="X")
|
wall_type = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWallType", predefined_type="X")
|
||||||
ifcopenshell.api.run("type.assign_type", ifc, related_object=wall, relating_type=wall_type)
|
ifcopenshell.api.run("type.assign_type", ifc, related_object=wall, relating_type=wall_type)
|
||||||
facet = ids.entity.create(name="IFCWALL", predefinedType="X")
|
facet = ids.entity.create(name="IFCWALL", predefinedType="X")
|
||||||
case("Inherited predefined types should pass", facet=facet, inst=wall, expected=True)
|
run("Inherited predefined types should pass", facet=facet, inst=wall, expected=True)
|
||||||
|
|
||||||
wall = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall", predefined_type="X")
|
wall = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall", predefined_type="X")
|
||||||
wall_type = ifcopenshell.api.run(
|
wall_type = ifcopenshell.api.run(
|
||||||
@@ -374,30 +379,30 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
ifcopenshell.api.run("type.assign_type", ifc, related_object=wall, relating_type=wall_type)
|
ifcopenshell.api.run("type.assign_type", ifc, related_object=wall, relating_type=wall_type)
|
||||||
facet = ids.entity.create(name="IFCWALL", predefinedType="X")
|
facet = ids.entity.create(name="IFCWALL", predefinedType="X")
|
||||||
case("Overridden predefined types should pass", facet=facet, inst=wall, expected=True)
|
run("Overridden predefined types should pass", facet=facet, inst=wall, expected=True)
|
||||||
|
|
||||||
# Restrictions are allowed when matching the IFC class
|
# Restrictions are allowed when matching the IFC class
|
||||||
restriction = ids.restriction.create(options=["IFCWALL", "IFCSLAB"], type="enumeration")
|
restriction = ids.restriction.create(options=["IFCWALL", "IFCSLAB"], type="enumeration")
|
||||||
facet = ids.entity.create(name=restriction)
|
facet = ids.entity.create(name=restriction)
|
||||||
case("Entities can be specified as an enumeration 1/3", facet=facet, inst=ifc.createIfcWall(), expected=True)
|
run("Entities can be specified as an enumeration 1/3", facet=facet, inst=ifc.createIfcWall(), expected=True)
|
||||||
case("Entities can be specified as an enumeration 2/3", facet=facet, inst=ifc.createIfcSlab(), expected=True)
|
run("Entities can be specified as an enumeration 2/3", facet=facet, inst=ifc.createIfcSlab(), expected=True)
|
||||||
case("Entities can be specified as an enumeration 3/3", facet=facet, inst=ifc.createIfcBeam(), expected=False)
|
run("Entities can be specified as an enumeration 3/3", facet=facet, inst=ifc.createIfcBeam(), expected=False)
|
||||||
|
|
||||||
# Another example of how restrictions are allowed when matching the IFC class
|
# Another example of how restrictions are allowed when matching the IFC class
|
||||||
# Note: Regex patterns follow the XSD flavour
|
# Note: Regex patterns follow the XSD flavour
|
||||||
restriction = ids.restriction.create(options="IFC.*TYPE", type="pattern")
|
restriction = ids.restriction.create(options="IFC.*TYPE", type="pattern")
|
||||||
facet = ids.entity.create(name=restriction)
|
facet = ids.entity.create(name=restriction)
|
||||||
case("Entities can be specified as a pattern 1/2", facet=facet, inst=ifc.createIfcWall(), expected=False)
|
run("Entities can be specified as a pattern 1/2", facet=facet, inst=ifc.createIfcWall(), expected=False)
|
||||||
case("Entities can be specified as a pattern 2/2", facet=facet, inst=ifc.createIfcWallType(), expected=True)
|
run("Entities can be specified as a pattern 2/2", facet=facet, inst=ifc.createIfcWallType(), expected=True)
|
||||||
|
|
||||||
restriction = ids.restriction.create(options="FOO.*", type="pattern")
|
restriction = ids.restriction.create(options="FOO.*", type="pattern")
|
||||||
facet = ids.entity.create(name="IFCWALL", predefinedType=restriction)
|
facet = ids.entity.create(name="IFCWALL", predefinedType=restriction)
|
||||||
wall = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall", predefined_type="FOOBAR")
|
wall = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall", predefined_type="FOOBAR")
|
||||||
wall2 = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall", predefined_type="FOOBAZ")
|
wall2 = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall", predefined_type="FOOBAZ")
|
||||||
wall3 = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall", predefined_type="BAZFOO")
|
wall3 = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall", predefined_type="BAZFOO")
|
||||||
case("Restrictions an be specified for the predefined type 1/3", facet=facet, inst=wall, expected=True)
|
run("Restrictions an be specified for the predefined type 1/3", facet=facet, inst=wall, expected=True)
|
||||||
case("Restrictions an be specified for the predefined type 2/3", facet=facet, inst=wall2, expected=True)
|
run("Restrictions an be specified for the predefined type 2/3", facet=facet, inst=wall2, expected=True)
|
||||||
case("Restrictions an be specified for the predefined type 3/3", facet=facet, inst=wall3, expected=False)
|
run("Restrictions an be specified for the predefined type 3/3", facet=facet, inst=wall3, expected=False)
|
||||||
|
|
||||||
def test_creating_an_attribute_facet(self):
|
def test_creating_an_attribute_facet(self):
|
||||||
attribute = ids.attribute.create(name="name")
|
attribute = ids.attribute.create(name="name")
|
||||||
@@ -416,46 +421,58 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def test_filtering_using_an_attribute_facet(self):
|
def test_filtering_using_an_attribute_facet(self):
|
||||||
|
set_facet("attribute")
|
||||||
|
|
||||||
ifc = ifcopenshell.file()
|
ifc = ifcopenshell.file()
|
||||||
|
|
||||||
# Attribute names that don't exist are never matched
|
|
||||||
facet = ids.attribute.create(name="Foobar")
|
facet = ids.attribute.create(name="Foobar")
|
||||||
case("", facet=facet, inst=ifc.createIfcWall(), expected=False)
|
run("Invalid attribute names always fail", facet=facet, inst=ifc.createIfcWall(), expected=False)
|
||||||
|
|
||||||
# Attribute names that are either null or empty string are not matched.
|
|
||||||
# The logic is that unfortunately most BIM users cannot differentiate between the two.
|
|
||||||
facet = ids.attribute.create(name="Name")
|
facet = ids.attribute.create(name="Name")
|
||||||
case("", facet=facet, inst=ifc.createIfcWall(), expected=False)
|
run("Attributes with a string value should pass", facet=facet, inst=ifc.createIfcWall(Name="Foobar"), expected=True)
|
||||||
case("", facet=facet, inst=ifc.createIfcWall(Name=""), expected=False)
|
run("Attributes with null values always fail", facet=facet, inst=ifc.createIfcWall(), expected=False)
|
||||||
case("", facet=facet, inst=ifc.createIfcWall(Name="Foobar"), expected=True)
|
# The logic is that unfortunately most BIM users cannot differentiate between the two.
|
||||||
# TODO write test case that evaluates empty list / set as False
|
run("Attributes with empty strings always fail", facet=facet, inst=ifc.createIfcWall(Name=""), expected=False)
|
||||||
# TODO write test case that evaluates logical UNKNOWN as False
|
facet = ids.attribute.create(name="CountValue")
|
||||||
# TODO write test case that evaluates any bool as True
|
run("Attributes with a zero number have meaning and should pass", facet=facet, inst=ifc.createIfcQuantityCount(Name="Foobar", CountValue=0), expected=True)
|
||||||
|
|
||||||
# An object value is truthy
|
facet = ids.attribute.create(name="IsCritical")
|
||||||
facet = ids.attribute.create(name="OwnerHistory")
|
element = ifc.createIfcTaskTime(IsCritical=True)
|
||||||
assert bool(facet(ifc.createIfcWall())) is False
|
run("Attributes with a boolean true should pass", facet=facet, inst=element, expected=True)
|
||||||
assert bool(facet(ifc.createIfcWall(OwnerHistory=ifc.createIfcOwnerHistory()))) is True
|
element.IsCritical = False
|
||||||
|
run("Attributes with a boolean false should pass", facet=facet, inst=element, expected=True)
|
||||||
|
|
||||||
|
facet = ids.attribute.create(name="RelatingPriorities")
|
||||||
|
run("Attributes with an empty list always fail", facet=facet, inst=ifc.createIfcRelConnectsPathElements(RelatingElement=ifc.createIfcWall(), RelatedElement=ifc.createIfcWall(), RelatingPriorities=[], RelatedPriorities=[], RelatedConnectionType="ATSTART", RelatingConnectionType="ATEND"), expected=False)
|
||||||
|
|
||||||
|
facet = ids.attribute.create(name="LayerStyles")
|
||||||
|
item = ifc.createIfcCartesianPoint([0., 0., 0.])
|
||||||
|
layer = ifc.createIfcPresentationLayerWithStyle("Foo", None, [item], None, True, False, False, [])
|
||||||
|
run("Attributes with an empty set always fail", facet=facet, inst=layer, expected=False)
|
||||||
|
|
||||||
|
layer.LayerOn = "UNKNOWN"
|
||||||
|
facet = ids.attribute.create(name="LayerOn")
|
||||||
|
run("Attributes with a logical unknown always fail", facet=facet, inst=layer, expected=False)
|
||||||
|
|
||||||
|
facet = ids.attribute.create(name="ScheduleDuration")
|
||||||
|
element = ifc.createIfcTaskTime(ScheduleDuration="P0D")
|
||||||
|
run("Attributes with a zero duration should pass", facet=facet, inst=element, expected=True)
|
||||||
|
|
||||||
|
facet = ids.attribute.create(name="TaskTime")
|
||||||
|
element = ifc.createIfcTask(IsMilestone=True, TaskTime=ifc.createIfcTaskTime())
|
||||||
|
run("Attributes referencing an object should pass", facet=facet, inst=element, expected=True)
|
||||||
|
|
||||||
# Selects are only considered for truthy or falsey
|
# Selects are only considered for truthy or falsey
|
||||||
facet = ids.attribute.create(name="DiffuseColour")
|
facet = ids.attribute.create(name="DiffuseColour")
|
||||||
element = ifc.createIfcSurfaceStyleRendering()
|
element = ifc.createIfcSurfaceStyleRendering()
|
||||||
assert bool(facet(element)) is False
|
rgb = ifc.createIfcColourRgb(None, 1, 1, 1)
|
||||||
assert bool(facet(ifc.createIfcSurfaceStyleRendering(DiffuseColour=ifc.createIfcColourRgb()))) is True
|
run("Attributes with a select referencing an object should pass", facet=facet, inst=ifc.createIfcSurfaceStyleRendering(SurfaceColour=rgb, ReflectanceMethod="FLAT", DiffuseColour=ifc.createIfcColourRgb(None, 1, 1, 1)), expected=True)
|
||||||
assert (
|
run("Attributes with a select referencing a primitive should pass", facet=facet, inst=ifc.createIfcSurfaceStyleRendering(SurfaceColour=rgb, ReflectanceMethod="FLAT", DiffuseColour=ifc.createIfcNormalisedRatioMeasure(0.5)), expected=True)
|
||||||
bool(facet(ifc.createIfcSurfaceStyleRendering(DiffuseColour=ifc.createIfcNormalisedRatioMeasure(0.5))))
|
|
||||||
is True
|
|
||||||
)
|
|
||||||
|
|
||||||
# When a value is specified, the value shall match case sensitively
|
# When a value is specified, the value shall match case sensitively
|
||||||
facet = ids.attribute.create(name="Name", value="Foobar")
|
facet = ids.attribute.create(name="Name", value="Foobar")
|
||||||
case("", facet=facet, inst=ifc.createIfcWall(Name="Foobar"), expected=True)
|
run("Attributes should check strings case sensitively 1/2", facet=facet, inst=ifc.createIfcWall(Name="Foobar"), expected=True)
|
||||||
case("", facet=facet, inst=ifc.createIfcWall(Name="foobar"), expected=False)
|
run("Attributes should check strings case sensitively 2/2", facet=facet, inst=ifc.createIfcWall(Name="foobar"), expected=False)
|
||||||
case("", facet=facet, inst=ifc.createIfcWall(Name="Foobaz"), expected=False)
|
|
||||||
|
|
||||||
# A value that is 0 is still considered a value, not "null-like", so it is matched
|
|
||||||
facet = ids.attribute.create(name="Eastings")
|
|
||||||
case("", facet=facet, inst=ifc.createIfcMapConversion(Eastings=0), expected=True)
|
|
||||||
|
|
||||||
# Value checks are meaningless for checking objects, selects, and lists so it always fails
|
# Value checks are meaningless for checking objects, selects, and lists so it always fails
|
||||||
facet = ids.attribute.create(name="OwnerHistory", value="Foobar")
|
facet = ids.attribute.create(name="OwnerHistory", value="Foobar")
|
||||||
@@ -475,8 +492,8 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
|
|
||||||
# Simple values which must be strings are checked with strict typing. No type casting shall occur.
|
# Simple values which must be strings are checked with strict typing. No type casting shall occur.
|
||||||
facet = ids.attribute.create(name="Eastings", value="42")
|
facet = ids.attribute.create(name="Eastings", value="42")
|
||||||
case("", facet=facet, inst=ifc.createIfcMapConversion(Eastings=0), expected=False)
|
run("", facet=facet, inst=ifc.createIfcMapConversion(Eastings=0), expected=False)
|
||||||
case("", facet=facet, inst=ifc.createIfcMapConversion(Eastings=42), expected=False)
|
run("", facet=facet, inst=ifc.createIfcMapConversion(Eastings=42), expected=False)
|
||||||
|
|
||||||
# Strict type checking is done with restrictions. This is really ugly, but hopefully hidden to a user.
|
# Strict type checking is done with restrictions. This is really ugly, but hopefully hidden to a user.
|
||||||
restriction = ids.restriction.create(options=[42], type="enumeration", base="decimal")
|
restriction = ids.restriction.create(options=[42], type="enumeration", base="decimal")
|
||||||
@@ -485,47 +502,47 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
# options={"minInclusive": 42, "maxInclusive": 42}, type="bounds", base="decimal"
|
# options={"minInclusive": 42, "maxInclusive": 42}, type="bounds", base="decimal"
|
||||||
# )
|
# )
|
||||||
facet = ids.attribute.create(name="Eastings", value=restriction)
|
facet = ids.attribute.create(name="Eastings", value=restriction)
|
||||||
case("", facet=facet, inst=ifc.createIfcMapConversion(Eastings=42), expected=True)
|
run("", facet=facet, inst=ifc.createIfcMapConversion(Eastings=42), expected=True)
|
||||||
|
|
||||||
# Restrictions are allowed for the name
|
# Restrictions are allowed for the name
|
||||||
restriction = ids.restriction.create(options=".*Name.*", type="pattern")
|
restriction = ids.restriction.create(options=".*Name.*", type="pattern")
|
||||||
facet = ids.attribute.create(name=restriction)
|
facet = ids.attribute.create(name=restriction)
|
||||||
case("", facet=facet, inst=ifc.createIfcMaterialLayerSet(LayerSetName="Foo"), expected=True)
|
run("", facet=facet, inst=ifc.createIfcMaterialLayerSet(LayerSetName="Foo"), expected=True)
|
||||||
case("", facet=facet, inst=ifc.createIfcMaterialConstituentSet(Name="Foo"), expected=True)
|
run("", facet=facet, inst=ifc.createIfcMaterialConstituentSet(Name="Foo"), expected=True)
|
||||||
|
|
||||||
# Restrictions for the name imply that multiple names may be matched. All, not any, must pass the checks.
|
# Restrictions for the name imply that multiple names may be matched. All, not any, must pass the checks.
|
||||||
restriction = ids.restriction.create(options=["Name", "Description"], type="enumeration")
|
restriction = ids.restriction.create(options=["Name", "Description"], type="enumeration")
|
||||||
facet = ids.attribute.create(name=restriction)
|
facet = ids.attribute.create(name=restriction)
|
||||||
case("", facet=facet, inst=ifc.createIfcWall(Name="Foo"), expected=False)
|
run("", facet=facet, inst=ifc.createIfcWall(Name="Foo"), expected=False)
|
||||||
case("", facet=facet, inst=ifc.createIfcWall(Name="Foo", Description="Bar"), expected=True)
|
run("", facet=facet, inst=ifc.createIfcWall(Name="Foo", Description="Bar"), expected=True)
|
||||||
|
|
||||||
# Restrictions are allowed for the value
|
# Restrictions are allowed for the value
|
||||||
restriction = ids.restriction.create(options=["Foo", "Bar"], type="enumeration")
|
restriction = ids.restriction.create(options=["Foo", "Bar"], type="enumeration")
|
||||||
facet = ids.attribute.create(name="Name", value=restriction)
|
facet = ids.attribute.create(name="Name", value=restriction)
|
||||||
case("", facet=facet, inst=ifc.createIfcWall(Name="Foo"), expected=True)
|
run("", facet=facet, inst=ifc.createIfcWall(Name="Foo"), expected=True)
|
||||||
case("", facet=facet, inst=ifc.createIfcWall(Name="Bar"), expected=True)
|
run("", facet=facet, inst=ifc.createIfcWall(Name="Bar"), expected=True)
|
||||||
case("", facet=facet, inst=ifc.createIfcWall(Name="Foobar"), expected=False)
|
run("", facet=facet, inst=ifc.createIfcWall(Name="Foobar"), expected=False)
|
||||||
|
|
||||||
# The facet checks on attributes on the type, which may be inherited by the occurence
|
# The facet checks on attributes on the type, which may be inherited by the occurence
|
||||||
# TODO attribute inheritance is not defined IFC behaviour
|
# TODO attribute inheritance is not defined IFC behaviour
|
||||||
facet = ids.attribute.create(name="Description", value="Foobar")
|
facet = ids.attribute.create(name="Description", value="Foobar")
|
||||||
case("", facet=facet, inst=ifc.createIfcWall(Description="Foobar"), expected=True)
|
run("", facet=facet, inst=ifc.createIfcWall(Description="Foobar"), expected=True)
|
||||||
wall = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
wall = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
wall_type = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWallType")
|
wall_type = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWallType")
|
||||||
ifcopenshell.api.run("type.assign_type", ifc, related_object=wall, relating_type=wall_type)
|
ifcopenshell.api.run("type.assign_type", ifc, related_object=wall, relating_type=wall_type)
|
||||||
wall_type.Description = "Foobar"
|
wall_type.Description = "Foobar"
|
||||||
case("", facet=facet, inst=wall, expected=True)
|
run("", facet=facet, inst=wall, expected=True)
|
||||||
|
|
||||||
# The facet checks on attributes on the type, which may be overriden by attributes on the occurence
|
# The facet checks on attributes on the type, which may be overriden by attributes on the occurence
|
||||||
# TODO attribute overriding is not defined IFC behaviour
|
# TODO attribute overriding is not defined IFC behaviour
|
||||||
facet = ids.attribute.create(name="Description", value="Foobar")
|
facet = ids.attribute.create(name="Description", value="Foobar")
|
||||||
case("", facet=facet, inst=ifc.createIfcWall(Description="Foobar"), expected=True)
|
run("", facet=facet, inst=ifc.createIfcWall(Description="Foobar"), expected=True)
|
||||||
wall = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
wall = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
wall_type = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWallType")
|
wall_type = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWallType")
|
||||||
ifcopenshell.api.run("type.assign_type", ifc, related_object=wall, relating_type=wall_type)
|
ifcopenshell.api.run("type.assign_type", ifc, related_object=wall, relating_type=wall_type)
|
||||||
wall_type.Description = "Foobaz"
|
wall_type.Description = "Foobaz"
|
||||||
wall.Description = "Foobar"
|
wall.Description = "Foobar"
|
||||||
case("", facet=facet, inst=wall, expected=True)
|
run("", facet=facet, inst=wall, expected=True)
|
||||||
|
|
||||||
def test_creating_a_classification_facet(self):
|
def test_creating_a_classification_facet(self):
|
||||||
facet = ids.classification.create()
|
facet = ids.classification.create()
|
||||||
@@ -581,43 +598,43 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
|
|
||||||
# A classification facet with no data matches any present classification
|
# A classification facet with no data matches any present classification
|
||||||
facet = ids.classification.create()
|
facet = ids.classification.create()
|
||||||
case("", facet=facet, inst=element0, expected=False)
|
run("", facet=facet, inst=element0, expected=False)
|
||||||
case("", facet=facet, inst=element1, expected=True)
|
run("", facet=facet, inst=element1, expected=True)
|
||||||
|
|
||||||
# Values should match exactly if lightweight classifications are used.
|
# Values should match exactly if lightweight classifications are used.
|
||||||
facet = ids.classification.create(value="1")
|
facet = ids.classification.create(value="1")
|
||||||
case("", facet=facet, inst=element1, expected=True)
|
run("", facet=facet, inst=element1, expected=True)
|
||||||
|
|
||||||
# Values should match subreferences if full classifications are used.
|
# Values should match subreferences if full classifications are used.
|
||||||
# E.g. a facet searching for Uniclass EF_25_10 Walls will match Uniclass EF_25_10_25, EF_25_10_30, etc
|
# E.g. a facet searching for Uniclass EF_25_10 Walls will match Uniclass EF_25_10_25, EF_25_10_30, etc
|
||||||
facet = ids.classification.create(value="2")
|
facet = ids.classification.create(value="2")
|
||||||
case("", facet=facet, inst=element22, expected=True)
|
run("", facet=facet, inst=element22, expected=True)
|
||||||
|
|
||||||
# Systems should match exactly regardless of lightweight or full classifications
|
# Systems should match exactly regardless of lightweight or full classifications
|
||||||
facet = ids.classification.create(system="Foobar")
|
facet = ids.classification.create(system="Foobar")
|
||||||
case("", facet=facet, inst=project, expected=True)
|
run("", facet=facet, inst=project, expected=True)
|
||||||
case("", facet=facet, inst=element0, expected=False)
|
run("", facet=facet, inst=element0, expected=False)
|
||||||
case("", facet=facet, inst=element1, expected=True)
|
run("", facet=facet, inst=element1, expected=True)
|
||||||
case("", facet=facet, inst=element11, expected=True)
|
run("", facet=facet, inst=element11, expected=True)
|
||||||
case("", facet=facet, inst=element22, expected=True)
|
run("", facet=facet, inst=element22, expected=True)
|
||||||
|
|
||||||
# Restrictions can be used for values
|
# Restrictions can be used for values
|
||||||
restriction = ids.restriction.create(options="1.*", type="pattern")
|
restriction = ids.restriction.create(options="1.*", type="pattern")
|
||||||
facet = ids.classification.create(value=restriction)
|
facet = ids.classification.create(value=restriction)
|
||||||
case("", facet=facet, inst=element1, expected=True)
|
run("", facet=facet, inst=element1, expected=True)
|
||||||
case("", facet=facet, inst=element11, expected=True)
|
run("", facet=facet, inst=element11, expected=True)
|
||||||
case("", facet=facet, inst=element22, expected=False)
|
run("", facet=facet, inst=element22, expected=False)
|
||||||
|
|
||||||
# Restrictions can be used for systems
|
# Restrictions can be used for systems
|
||||||
restriction = ids.restriction.create(options="Foo.*", type="pattern")
|
restriction = ids.restriction.create(options="Foo.*", type="pattern")
|
||||||
facet = ids.classification.create(system=restriction)
|
facet = ids.classification.create(system=restriction)
|
||||||
case("", facet=facet, inst=element0, expected=False)
|
run("", facet=facet, inst=element0, expected=False)
|
||||||
case("", facet=facet, inst=element1, expected=True)
|
run("", facet=facet, inst=element1, expected=True)
|
||||||
|
|
||||||
# Specifying both a value and a system means that both (as opposed to either) requirements must be met
|
# Specifying both a value and a system means that both (as opposed to either) requirements must be met
|
||||||
facet = ids.classification.create(system="Foobar", value="1")
|
facet = ids.classification.create(system="Foobar", value="1")
|
||||||
case("", facet=facet, inst=element1, expected=True)
|
run("", facet=facet, inst=element1, expected=True)
|
||||||
case("", facet=facet, inst=element11, expected=False)
|
run("", facet=facet, inst=element11, expected=False)
|
||||||
|
|
||||||
# The facet checks on either the type or instance.
|
# The facet checks on either the type or instance.
|
||||||
# IFC doesn't specify how inheritance and overrides work here. Two options:
|
# IFC doesn't specify how inheritance and overrides work here. Two options:
|
||||||
@@ -632,11 +649,11 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
"classification.add_reference", ifc, product=wall_type, reference=ref22, classification=system
|
"classification.add_reference", ifc, product=wall_type, reference=ref22, classification=system
|
||||||
)
|
)
|
||||||
facet = ids.classification.create(value="11")
|
facet = ids.classification.create(value="11")
|
||||||
case("", facet=facet, inst=wall, expected=True)
|
run("", facet=facet, inst=wall, expected=True)
|
||||||
case("", facet=facet, inst=wall_type, expected=False)
|
run("", facet=facet, inst=wall_type, expected=False)
|
||||||
facet = ids.classification.create(value="22")
|
facet = ids.classification.create(value="22")
|
||||||
case("", facet=facet, inst=wall, expected=True)
|
run("", facet=facet, inst=wall, expected=True)
|
||||||
case("", facet=facet, inst=wall_type, expected=True)
|
run("", facet=facet, inst=wall_type, expected=True)
|
||||||
|
|
||||||
def test_creating_a_property_facet(self):
|
def test_creating_a_property_facet(self):
|
||||||
facet = ids.property.create()
|
facet = ids.property.create()
|
||||||
@@ -683,31 +700,31 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
# The logic is that unfortunately most BIM users cannot differentiate between the two.
|
# The logic is that unfortunately most BIM users cannot differentiate between the two.
|
||||||
facet = ids.property.create(propertySet="Foo_Bar", name="Foo")
|
facet = ids.property.create(propertySet="Foo_Bar", name="Foo")
|
||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": None})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": None})
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Bar"})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Bar"})
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
|
|
||||||
# A simple value checks an exact case-sensitive match
|
# A simple value checks an exact case-sensitive match
|
||||||
facet = ids.property.create(propertySet="Foo_Bar", name="Foo", value="Bar")
|
facet = ids.property.create(propertySet="Foo_Bar", name="Foo", value="Bar")
|
||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Bar"})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Bar"})
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Baz"})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Baz"})
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
|
|
||||||
# Simple values only check string matches
|
# Simple values only check string matches
|
||||||
facet = ids.property.create(propertySet="Foo_Bar", name="Foo", value="1")
|
facet = ids.property.create(propertySet="Foo_Bar", name="Foo", value="1")
|
||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "1"})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "1"})
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcInteger(1)})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcInteger(1)})
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
|
|
||||||
# Restrictions are supported for property sets. If multiple are matched, all must satisfy requirements.
|
# Restrictions are supported for property sets. If multiple are matched, all must satisfy requirements.
|
||||||
restriction = ids.restriction.create(options="Foo_.*", type="pattern")
|
restriction = ids.restriction.create(options="Foo_.*", type="pattern")
|
||||||
@@ -715,11 +732,11 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Bar"})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Bar"})
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Baz")
|
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Baz")
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Bar"})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Bar"})
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
|
|
||||||
# Restrictions are supported for names. If multiple are matched, all must satisfy requirements.
|
# Restrictions are supported for names. If multiple are matched, all must satisfy requirements.
|
||||||
restriction = ids.restriction.create(options="Foo.*", type="pattern")
|
restriction = ids.restriction.create(options="Foo.*", type="pattern")
|
||||||
@@ -727,11 +744,11 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": "x"})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": "x"})
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": "x", "Foobaz": "x"})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": "x", "Foobaz": "x"})
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": "x", "Foobaz": "y"})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": "x", "Foobaz": "y"})
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
|
|
||||||
# Restrictions are supported for values. If multiple are matched, all must satisfy requirements.
|
# Restrictions are supported for values. If multiple are matched, all must satisfy requirements.
|
||||||
restriction1 = ids.restriction.create(options="Foo.*", type="pattern")
|
restriction1 = ids.restriction.create(options="Foo.*", type="pattern")
|
||||||
@@ -740,9 +757,9 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": "x", "Foobaz": "y"})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": "x", "Foobaz": "y"})
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": "x", "Foobaz": "z"})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": "x", "Foobaz": "z"})
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
|
|
||||||
# Restrictions may be used to check basic data primitives
|
# Restrictions may be used to check basic data primitives
|
||||||
restriction = ids.restriction.create(options=[42.12], type="enumeration", base="decimal")
|
restriction = ids.restriction.create(options=[42.12], type="enumeration", base="decimal")
|
||||||
@@ -750,19 +767,19 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": 42.12})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": 42.12})
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
restriction = ids.restriction.create(options=[42], type="enumeration", base="integer")
|
restriction = ids.restriction.create(options=[42], type="enumeration", base="integer")
|
||||||
facet = ids.property.create(propertySet="Foo_Bar", name="Foobar", value=restriction)
|
facet = ids.property.create(propertySet="Foo_Bar", name="Foobar", value=restriction)
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": 42})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": 42})
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
restriction = ids.restriction.create(options=[True], type="enumeration", base="boolean")
|
restriction = ids.restriction.create(options=[True], type="enumeration", base="boolean")
|
||||||
facet = ids.property.create(propertySet="Foo_Bar", name="Foobar", value=restriction)
|
facet = ids.property.create(propertySet="Foo_Bar", name="Foobar", value=restriction)
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": True})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": True})
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": False})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": False})
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
|
|
||||||
# When measure is not specified, no unit conversion is done and only primitives are checked
|
# When measure is not specified, no unit conversion is done and only primitives are checked
|
||||||
restriction = ids.restriction.create(options=[42.12], type="enumeration", base="decimal")
|
restriction = ids.restriction.create(options=[42.12], type="enumeration", base="decimal")
|
||||||
@@ -770,7 +787,7 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": 42.12})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": 42.12})
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
|
|
||||||
# Measure may be used to specify an IFC data type
|
# Measure may be used to specify an IFC data type
|
||||||
restriction = ids.restriction.create(options=[2], type="enumeration", base="decimal")
|
restriction = ids.restriction.create(options=[2], type="enumeration", base="decimal")
|
||||||
@@ -778,9 +795,9 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcMassMeasure(2)})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcMassMeasure(2)})
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcTimeMeasure(2)})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcTimeMeasure(2)})
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
|
|
||||||
# Measure also implies that a unit matters, and so a conversion shall take place to SI units
|
# Measure also implies that a unit matters, and so a conversion shall take place to SI units
|
||||||
restriction = ids.restriction.create(options=[2], type="enumeration", base="decimal")
|
restriction = ids.restriction.create(options=[2], type="enumeration", base="decimal")
|
||||||
@@ -788,9 +805,9 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcLengthMeasure(2)})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcLengthMeasure(2)})
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcLengthMeasure(2000)})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcLengthMeasure(2000)})
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
|
|
||||||
# The facet checks inherited properties from the type
|
# The facet checks inherited properties from the type
|
||||||
wall = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
wall = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
@@ -799,8 +816,8 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=wall_type, name="Foo_Bar")
|
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=wall_type, name="Foo_Bar")
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Bar"})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Bar"})
|
||||||
facet = ids.property.create(propertySet="Foo_Bar", name="Foo")
|
facet = ids.property.create(propertySet="Foo_Bar", name="Foo")
|
||||||
case("", facet=facet, inst=wall, expected=True)
|
run("", facet=facet, inst=wall, expected=True)
|
||||||
case("", facet=facet, inst=wall_type, expected=True)
|
run("", facet=facet, inst=wall_type, expected=True)
|
||||||
|
|
||||||
# The facet checks overriden properties from the occurrence
|
# The facet checks overriden properties from the occurrence
|
||||||
wall = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
wall = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
@@ -811,8 +828,8 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=wall, name="Foo_Bar")
|
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=wall, name="Foo_Bar")
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Bar"})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Bar"})
|
||||||
facet = ids.property.create(propertySet="Foo_Bar", name="Foo", value="Bar")
|
facet = ids.property.create(propertySet="Foo_Bar", name="Foo", value="Bar")
|
||||||
case("", facet=facet, inst=wall, expected=True)
|
run("", facet=facet, inst=wall, expected=True)
|
||||||
case("", facet=facet, inst=wall_type, expected=False)
|
run("", facet=facet, inst=wall_type, expected=False)
|
||||||
|
|
||||||
def test_creating_a_material_facet(self):
|
def test_creating_a_material_facet(self):
|
||||||
facet = ids.material.create()
|
facet = ids.material.create()
|
||||||
@@ -834,98 +851,98 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
# A material facet with no data matches any present material
|
# A material facet with no data matches any present material
|
||||||
facet = ids.material.create()
|
facet = ids.material.create()
|
||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
material = ifcopenshell.api.run("material.add_material", ifc)
|
material = ifcopenshell.api.run("material.add_material", ifc)
|
||||||
ifcopenshell.api.run("material.assign_material", ifc, product=element, material=material)
|
ifcopenshell.api.run("material.assign_material", ifc, product=element, material=material)
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
|
|
||||||
# A value will match a material name or category
|
# A value will match a material name or category
|
||||||
facet = ids.material.create(value="Foo")
|
facet = ids.material.create(value="Foo")
|
||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
material = ifcopenshell.api.run("material.add_material", ifc)
|
material = ifcopenshell.api.run("material.add_material", ifc)
|
||||||
ifcopenshell.api.run("material.assign_material", ifc, product=element, material=material)
|
ifcopenshell.api.run("material.assign_material", ifc, product=element, material=material)
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
material.Name = "Foo"
|
material.Name = "Foo"
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
material.Name = "Bar"
|
material.Name = "Bar"
|
||||||
material.Category = "Foo"
|
material.Category = "Foo"
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
|
|
||||||
# A value will match any material name or category in a material list
|
# A value will match any material name or category in a material list
|
||||||
facet = ids.material.create(value="Foo")
|
facet = ids.material.create(value="Foo")
|
||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
material_set = ifcopenshell.api.run("material.add_material_set", ifc, set_type="IfcMaterialList")
|
material_set = ifcopenshell.api.run("material.add_material_set", ifc, set_type="IfcMaterialList")
|
||||||
ifcopenshell.api.run("material.assign_material", ifc, product=element, material=material_set)
|
ifcopenshell.api.run("material.assign_material", ifc, product=element, material=material_set)
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
material = ifcopenshell.api.run("material.add_material", ifc)
|
material = ifcopenshell.api.run("material.add_material", ifc)
|
||||||
ifcopenshell.api.run("material.add_list_item", ifc, material_list=material_set, material=material)
|
ifcopenshell.api.run("material.add_list_item", ifc, material_list=material_set, material=material)
|
||||||
material.Name = "Foo"
|
material.Name = "Foo"
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
material.Name = "Bar"
|
material.Name = "Bar"
|
||||||
material.Category = "Foo"
|
material.Category = "Foo"
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
|
|
||||||
# A value will match any material name or category, or layer name or category in a layer set
|
# A value will match any material name or category, or layer name or category in a layer set
|
||||||
facet = ids.material.create(value="Foo")
|
facet = ids.material.create(value="Foo")
|
||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
material_set = ifcopenshell.api.run("material.add_material_set", ifc, set_type="IfcMaterialLayerSet")
|
material_set = ifcopenshell.api.run("material.add_material_set", ifc, set_type="IfcMaterialLayerSet")
|
||||||
ifcopenshell.api.run("material.assign_material", ifc, product=element, material=material_set)
|
ifcopenshell.api.run("material.assign_material", ifc, product=element, material=material_set)
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
material = ifcopenshell.api.run("material.add_material", ifc)
|
material = ifcopenshell.api.run("material.add_material", ifc)
|
||||||
layer = ifcopenshell.api.run("material.add_layer", ifc, layer_set=material_set, material=material)
|
layer = ifcopenshell.api.run("material.add_layer", ifc, layer_set=material_set, material=material)
|
||||||
layer.Name = "Foo"
|
layer.Name = "Foo"
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
layer.Name = "Bar"
|
layer.Name = "Bar"
|
||||||
layer.Category = "Foo"
|
layer.Category = "Foo"
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
layer.Category = "Bar"
|
layer.Category = "Bar"
|
||||||
material.Name = "Foo"
|
material.Name = "Foo"
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
material.Name = "Bar"
|
material.Name = "Bar"
|
||||||
material.Category = "Foo"
|
material.Category = "Foo"
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
|
|
||||||
# A value will match any material name or category, or profile name or category in a profile set
|
# A value will match any material name or category, or profile name or category in a profile set
|
||||||
facet = ids.material.create(value="Foo")
|
facet = ids.material.create(value="Foo")
|
||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
material_set = ifcopenshell.api.run("material.add_material_set", ifc, set_type="IfcMaterialProfileSet")
|
material_set = ifcopenshell.api.run("material.add_material_set", ifc, set_type="IfcMaterialProfileSet")
|
||||||
ifcopenshell.api.run("material.assign_material", ifc, product=element, material=material_set)
|
ifcopenshell.api.run("material.assign_material", ifc, product=element, material=material_set)
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
material = ifcopenshell.api.run("material.add_material", ifc)
|
material = ifcopenshell.api.run("material.add_material", ifc)
|
||||||
profile = ifcopenshell.api.run("material.add_profile", ifc, profile_set=material_set, material=material)
|
profile = ifcopenshell.api.run("material.add_profile", ifc, profile_set=material_set, material=material)
|
||||||
profile.Name = "Foo"
|
profile.Name = "Foo"
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
profile.Name = "Bar"
|
profile.Name = "Bar"
|
||||||
profile.Category = "Foo"
|
profile.Category = "Foo"
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
profile.Category = "Bar"
|
profile.Category = "Bar"
|
||||||
material.Name = "Foo"
|
material.Name = "Foo"
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
material.Name = "Bar"
|
material.Name = "Bar"
|
||||||
material.Category = "Foo"
|
material.Category = "Foo"
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
|
|
||||||
# A value will match any material name or category, or constituent name or category in a constituent set
|
# A value will match any material name or category, or constituent name or category in a constituent set
|
||||||
facet = ids.material.create(value="Foo")
|
facet = ids.material.create(value="Foo")
|
||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
material_set = ifcopenshell.api.run("material.add_material_set", ifc, set_type="IfcMaterialConstituentSet")
|
material_set = ifcopenshell.api.run("material.add_material_set", ifc, set_type="IfcMaterialConstituentSet")
|
||||||
ifcopenshell.api.run("material.assign_material", ifc, product=element, material=material_set)
|
ifcopenshell.api.run("material.assign_material", ifc, product=element, material=material_set)
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
material = ifcopenshell.api.run("material.add_material", ifc)
|
material = ifcopenshell.api.run("material.add_material", ifc)
|
||||||
constituent = ifcopenshell.api.run(
|
constituent = ifcopenshell.api.run(
|
||||||
"material.add_constituent", ifc, constituent_set=material_set, material=material
|
"material.add_constituent", ifc, constituent_set=material_set, material=material
|
||||||
)
|
)
|
||||||
constituent.Name = "Foo"
|
constituent.Name = "Foo"
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
constituent.Name = "Bar"
|
constituent.Name = "Bar"
|
||||||
constituent.Category = "Foo"
|
constituent.Category = "Foo"
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
constituent.Category = "Bar"
|
constituent.Category = "Bar"
|
||||||
material.Name = "Foo"
|
material.Name = "Foo"
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
material.Name = "Bar"
|
material.Name = "Bar"
|
||||||
material.Category = "Foo"
|
material.Category = "Foo"
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
|
|
||||||
# The facet will check for inherited materials
|
# The facet will check for inherited materials
|
||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
@@ -935,8 +952,8 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
ifcopenshell.api.run("material.assign_material", ifc, product=element_type, material=material)
|
ifcopenshell.api.run("material.assign_material", ifc, product=element_type, material=material)
|
||||||
material.Name = "Foo"
|
material.Name = "Foo"
|
||||||
facet = ids.material.create(value="Foo")
|
facet = ids.material.create(value="Foo")
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
case("", facet=facet, inst=element_type, expected=True)
|
run("", facet=facet, inst=element_type, expected=True)
|
||||||
|
|
||||||
# The facet will check for overriden materials
|
# The facet will check for overriden materials
|
||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
@@ -949,8 +966,8 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
ifcopenshell.api.run("material.assign_material", ifc, product=element, material=material)
|
ifcopenshell.api.run("material.assign_material", ifc, product=element, material=material)
|
||||||
material.Name = "Foo"
|
material.Name = "Foo"
|
||||||
facet = ids.material.create(value="Foo")
|
facet = ids.material.create(value="Foo")
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
case("", facet=facet, inst=element_type, expected=False)
|
run("", facet=facet, inst=element_type, expected=False)
|
||||||
|
|
||||||
def test_creating_a_partof_facet(self):
|
def test_creating_a_partof_facet(self):
|
||||||
facet = ids.partOf.create()
|
facet = ids.partOf.create()
|
||||||
@@ -966,15 +983,15 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
subelement = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
subelement = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||||
ifcopenshell.api.run("aggregate.assign_object", ifc, product=subelement, relating_object=element)
|
ifcopenshell.api.run("aggregate.assign_object", ifc, product=subelement, relating_object=element)
|
||||||
facet = ids.partOf.create(entity="IfcElementAssembly")
|
facet = ids.partOf.create(entity="IfcElementAssembly")
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
case("", facet=facet, inst=subelement, expected=True)
|
run("", facet=facet, inst=subelement, expected=True)
|
||||||
|
|
||||||
# An IfcElementAssembly strictly checks that the whole is an IfcElementAssembly class
|
# An IfcElementAssembly strictly checks that the whole is an IfcElementAssembly class
|
||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcSlab")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcSlab")
|
||||||
subelement = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcBeam")
|
subelement = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcBeam")
|
||||||
ifcopenshell.api.run("aggregate.assign_object", ifc, product=subelement, relating_object=element)
|
ifcopenshell.api.run("aggregate.assign_object", ifc, product=subelement, relating_object=element)
|
||||||
facet = ids.partOf.create(entity="IfcElementAssembly")
|
facet = ids.partOf.create(entity="IfcElementAssembly")
|
||||||
case("", facet=facet, inst=subelement, expected=False)
|
run("", facet=facet, inst=subelement, expected=False)
|
||||||
|
|
||||||
# A nested subelement still passes so long as one of its parents is an IfcElementAssembly
|
# A nested subelement still passes so long as one of its parents is an IfcElementAssembly
|
||||||
# TODO nononono
|
# TODO nononono
|
||||||
@@ -984,15 +1001,15 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
ifcopenshell.api.run("aggregate.assign_object", ifc, product=subelement, relating_object=element)
|
ifcopenshell.api.run("aggregate.assign_object", ifc, product=subelement, relating_object=element)
|
||||||
ifcopenshell.api.run("aggregate.assign_object", ifc, product=subsubelement, relating_object=subelement)
|
ifcopenshell.api.run("aggregate.assign_object", ifc, product=subsubelement, relating_object=subelement)
|
||||||
facet = ids.partOf.create(entity="IfcElementAssembly")
|
facet = ids.partOf.create(entity="IfcElementAssembly")
|
||||||
case("", facet=facet, inst=subsubelement, expected=True)
|
run("", facet=facet, inst=subsubelement, expected=True)
|
||||||
|
|
||||||
# An IfcGroup only checks that a group is assigned without any other logic
|
# An IfcGroup only checks that a group is assigned without any other logic
|
||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcElementAssembly")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcElementAssembly")
|
||||||
group = ifcopenshell.api.run("group.add_group", ifc)
|
group = ifcopenshell.api.run("group.add_group", ifc)
|
||||||
facet = ids.partOf.create(entity="IfcGroup")
|
facet = ids.partOf.create(entity="IfcGroup")
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
ifcopenshell.api.run("group.assign_group", ifc, product=element, group=group)
|
ifcopenshell.api.run("group.assign_group", ifc, product=element, group=group)
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
|
|
||||||
# An IfcGroup can be passed by subtypes
|
# An IfcGroup can be passed by subtypes
|
||||||
# TODO: wrong, subtypes should not be matched
|
# TODO: wrong, subtypes should not be matched
|
||||||
@@ -1000,15 +1017,15 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
group = ifc.createIfcInventory()
|
group = ifc.createIfcInventory()
|
||||||
facet = ids.partOf.create(entity="IfcGroup")
|
facet = ids.partOf.create(entity="IfcGroup")
|
||||||
ifcopenshell.api.run("group.assign_group", ifc, product=element, group=group)
|
ifcopenshell.api.run("group.assign_group", ifc, product=element, group=group)
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
|
|
||||||
# An IfcSystem only checks that a system is assigned without any other logic
|
# An IfcSystem only checks that a system is assigned without any other logic
|
||||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcElementAssembly")
|
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcElementAssembly")
|
||||||
system = ifcopenshell.api.run("system.add_system", ifc)
|
system = ifcopenshell.api.run("system.add_system", ifc)
|
||||||
facet = ids.partOf.create(entity="IfcSystem")
|
facet = ids.partOf.create(entity="IfcSystem")
|
||||||
case("", facet=facet, inst=element, expected=False)
|
run("", facet=facet, inst=element, expected=False)
|
||||||
ifcopenshell.api.run("system.assign_system", ifc, product=element, system=system)
|
ifcopenshell.api.run("system.assign_system", ifc, product=element, system=system)
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
|
|
||||||
# An IfcSystem allows subtypes
|
# An IfcSystem allows subtypes
|
||||||
# TODO: wrong, subtypes should not be matched
|
# TODO: wrong, subtypes should not be matched
|
||||||
@@ -1016,7 +1033,7 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
system = ifcopenshell.api.run("system.add_system", ifc, ifc_class="IfcDistributionSystem")
|
system = ifcopenshell.api.run("system.add_system", ifc, ifc_class="IfcDistributionSystem")
|
||||||
ifcopenshell.api.run("system.assign_system", ifc, product=element, system=system)
|
ifcopenshell.api.run("system.assign_system", ifc, product=element, system=system)
|
||||||
facet = ids.partOf.create(entity="IfcSystem")
|
facet = ids.partOf.create(entity="IfcSystem")
|
||||||
case("", facet=facet, inst=element, expected=True)
|
run("", facet=facet, inst=element, expected=True)
|
||||||
|
|
||||||
""" Creating IDS with restrictions """
|
""" Creating IDS with restrictions """
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user