From af4cb22756ffd44ebb6eeaf5d6a62d22c75973fb Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sat, 3 Sep 2022 22:16:35 +1000 Subject: [PATCH] Fix bug where appended assets sometimes duplicated geometry contexts --- .../ifcopenshell/api/project/append_asset.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py b/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py index cf1b3d4cf4..95045d3b41 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py +++ b/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py @@ -52,14 +52,14 @@ class Usecase: if [e for e in self.file.by_type("IfcMaterial") if e.Name == self.settings["element"].Name]: return self.whitelisted_inverse_attributes = {"IfcMaterial": ["HasProperties", "HasRepresentation"]} + self.existing_contexts = self.file.by_type("IfcGeometricRepresentationContext") element = self.add_element(self.settings["element"]) if not element.HasRepresentation: return element - self.existing_contexts = self.file.by_type("IfcGeometricRepresentationContext") added_contexts = [ e for e in self.file.traverse(element.HasRepresentation[0]) - if e.is_a() == "IfcGeometricRepresentationSubContext" + if e.is_a("IfcGeometricRepresentationContext") ] for added_context in added_contexts: equivalent_existing_context = self.get_equivalent_existing_context(added_context) @@ -93,9 +93,9 @@ class Usecase: "IfcMaterialDefinition": ["HasExternalReferences", "HasProperties"], "IfcRepresentationItem": ["StyledByItem"], } - element = self.add_element(self.settings["element"]) self.existing_contexts = self.file.by_type("IfcGeometricRepresentationContext") - added_contexts = [e for e in self.file.traverse(element) if e.is_a() == "IfcGeometricRepresentationContext"] + element = self.add_element(self.settings["element"]) + added_contexts = [e for e in self.file.traverse(element) if e.is_a("IfcGeometricRepresentationContext")] for added_context in added_contexts: equivalent_existing_context = self.get_equivalent_existing_context(added_context) if not equivalent_existing_context: @@ -117,9 +117,9 @@ class Usecase: "IfcMaterialDefinition": ["HasExternalReferences", "HasProperties"], "IfcRepresentationItem": ["StyledByItem"], } - element = self.add_element(self.settings["element"]) self.existing_contexts = self.file.by_type("IfcGeometricRepresentationContext") - added_contexts = [e for e in self.file.traverse(element) if e.is_a() == "IfcGeometricRepresentationContext"] + element = self.add_element(self.settings["element"]) + added_contexts = [e for e in self.file.traverse(element) if e.is_a("IfcGeometricRepresentationContext")] for added_context in added_contexts: equivalent_existing_context = self.get_equivalent_existing_context(added_context) if not equivalent_existing_context: