Fix #3948. Bug where IfcTester PartOf facet didn't correctly read entity XML.

This commit is contained in:
Dion Moult
2023-11-02 12:28:53 +11:00
parent 8b23c615c3
commit 2f951d352b
2 changed files with 50 additions and 48 deletions
+21 -21
View File
@@ -354,23 +354,23 @@ class Classification(Facet):
class PartOf(Facet):
def __init__(
self,
entity="IFCWALL",
name="IFCWALL",
predefinedType=None,
relation=None,
minOccurs=None,
maxOccurs="unbounded",
instructions=None,
):
self.parameters = ["entity", "predefinedType", "@relation", "@minOccurs", "@maxOccurs", "@instructions"]
self.parameters = ["name", "predefinedType", "@relation", "@minOccurs", "@maxOccurs", "@instructions"]
self.applicability_templates = [
"An element with an {relation} relationship with an {entity}",
"An element with an {relation} relationship with an {name}",
"An element with an {relation} relationship",
]
self.requirement_templates = [
"An element must have an {relation} relationship with an {entity}",
"An element must have an {relation} relationship with an {name}",
"An element must have an {relation} relationship",
]
super().__init__(entity, predefinedType, relation, minOccurs, maxOccurs, instructions)
super().__init__(name, predefinedType, relation, minOccurs, maxOccurs, instructions)
def filter(self, ifc_file, elements):
if isinstance(elements, list):
@@ -380,9 +380,9 @@ class PartOf(Facet):
def asdict(self):
results = super().asdict()
entity = {}
if "entity" in results:
entity["name"] = results["entity"]
del results["entity"]
if "name" in results:
entity["name"] = results["name"]
del results["name"]
if "predefinedType" in results:
entity["predefinedType"] = results["predefinedType"]
del results["predefinedType"]
@@ -407,7 +407,7 @@ class PartOf(Facet):
parent = self.get_parent(inst)
while parent:
ancestors.append(parent.is_a())
if parent.is_a().upper() == self.entity:
if parent.is_a().upper() == self.name:
if self.predefinedType:
if ifcopenshell.util.element.get_predefined_type(parent) == self.predefinedType:
is_pass = True
@@ -422,12 +422,12 @@ class PartOf(Facet):
is_pass = aggregate is not None
if not is_pass:
reason = {"type": "NOVALUE"}
if is_pass and self.entity:
if is_pass and self.name:
is_pass = False
ancestors = []
while aggregate is not None:
ancestors.append(aggregate.is_a())
if aggregate.is_a().upper() == self.entity:
if aggregate.is_a().upper() == self.name:
if self.predefinedType:
if ifcopenshell.util.element.get_predefined_type(aggregate) == self.predefinedType:
is_pass = True
@@ -446,8 +446,8 @@ class PartOf(Facet):
is_pass = group is not None
if not is_pass:
reason = {"type": "NOVALUE"}
if is_pass and self.entity:
if group.is_a().upper() != self.entity:
if is_pass and self.name:
if group.is_a().upper() != self.name:
is_pass = False
reason = {"type": "ENTITY", "actual": group.is_a().upper()}
if self.predefinedType:
@@ -460,8 +460,8 @@ class PartOf(Facet):
is_pass = container is not None
if not is_pass:
reason = {"type": "NOVALUE"}
if is_pass and self.entity:
if container.is_a().upper() != self.entity:
if is_pass and self.name:
if container.is_a().upper() != self.name:
is_pass = False
reason = {"type": "ENTITY", "actual": container.is_a().upper()}
if self.predefinedType:
@@ -474,12 +474,12 @@ class PartOf(Facet):
is_pass = nest is not None
if not is_pass:
reason = {"type": "NOVALUE"}
if is_pass and self.entity:
if is_pass and self.name:
is_pass = False
ancestors = []
while nest is not None:
ancestors.append(nest.is_a())
if nest.is_a().upper() == self.entity:
if nest.is_a().upper() == self.name:
if self.predefinedType:
if ifcopenshell.util.element.get_predefined_type(nest) == self.predefinedType:
is_pass = True
@@ -494,9 +494,9 @@ class PartOf(Facet):
is_pass = building_element is not None
if not is_pass:
reason = {"type": "NOVALUE"}
if is_pass and self.entity:
if is_pass and self.name:
is_pass = False
if building_element.is_a().upper() == self.entity:
if building_element.is_a().upper() == self.name:
if self.predefinedType:
if ifcopenshell.util.element.get_predefined_type(building_element) == self.predefinedType:
is_pass = True
@@ -509,9 +509,9 @@ class PartOf(Facet):
is_pass = opening is not None
if not is_pass:
reason = {"type": "NOVALUE"}
if is_pass and self.entity:
if is_pass and self.name:
is_pass = False
if opening.is_a().upper() == self.entity:
if opening.is_a().upper() == self.name:
if self.predefinedType:
if ifcopenshell.util.element.get_predefined_type(opening) == self.predefinedType:
is_pass = True