Fix #7213. IfcTester now supports checking for USERDEFINED predefined types

Can I just take this moment to complain about the overengineered
complexity of how predefined types work in IFC.
This commit is contained in:
Dion Moult
2025-10-11 21:09:41 +11:00
parent b68e8dedd2
commit cb5c488cfd
4 changed files with 102 additions and 4 deletions
+7 -2
View File
@@ -227,8 +227,13 @@ class Entity(Facet):
reason = {"type": "NAME", "actual": inst.is_a().upper()}
if is_pass and self.predefinedType:
predefined_type = ifcopenshell.util.element.get_predefined_type(inst)
is_pass = predefined_type == self.predefinedType
if self.predefinedType == "USERDEFINED":
is_pass = ifcopenshell.util.element.is_userdefined_type(inst)
if not is_pass:
predefined_type = ifcopenshell.util.element.get_predefined_type(inst)
else:
predefined_type = ifcopenshell.util.element.get_predefined_type(inst)
is_pass = predefined_type == self.predefinedType
if not is_pass:
reason = {"type": "PREDEFINEDTYPE", "actual": predefined_type}
+2 -2
View File
@@ -172,10 +172,10 @@ class TestEntity:
facet = Entity(name="IFCWALL", predefinedType="USERDEFINED")
ifc = ifcopenshell.file()
run(
"A predefined type must always specify a meaningful type, not USERDEFINED itself",
"A predefined type may specify USERDEFINED itself",
facet=facet,
inst=ifc.createIfcWall(PredefinedType="USERDEFINED", ObjectType="WALDO"),
expected=False,
expected=True,
)
ifc = ifcopenshell.file()