From e43347161ae5db8d7474dbe6747945f271f197f0 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 8 Aug 2023 22:35:27 +1000 Subject: [PATCH] Fix #3547. Bug where using existing clippings were not preserved when editing profile or wall representations. --- .../api/geometry/add_profile_representation.py | 8 ++++++-- .../ifcopenshell/api/geometry/add_wall_representation.py | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_profile_representation.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_profile_representation.py index d2eddcdeb0..fe028bc657 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_profile_representation.py +++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_profile_representation.py @@ -63,7 +63,11 @@ class Usecase: def apply_clippings(self, first_operand): while self.settings["clippings"]: clipping = self.settings["clippings"].pop() - if clipping["operand_type"] == "IfcHalfSpaceSolid": + if isinstance(clipping, ifcopenshell.entity_instance): + new = ifcopenshell.util.element.copy(self.file, clipping) + new.FirstOperand = first_operand + first_operand = new + elif clipping["operand_type"] == "IfcHalfSpaceSolid": matrix = clipping["matrix"] second_operand = self.file.createIfcHalfSpaceSolid( self.file.createIfcPlane( @@ -81,7 +85,7 @@ class Usecase: ), False, ) - first_operand = self.file.create_entity(clipping["type"], "DIFFERENCE", first_operand, second_operand) + first_operand = self.file.create_entity(clipping["type"], "DIFFERENCE", first_operand, second_operand) return first_operand def convert_si_to_unit(self, co): diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_wall_representation.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_wall_representation.py index c146c8cdf3..799e1b252f 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_wall_representation.py +++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_wall_representation.py @@ -95,7 +95,11 @@ class Usecase: def apply_clippings(self, first_operand): while self.settings["clippings"]: clipping = self.settings["clippings"].pop() - if clipping["operand_type"] == "IfcHalfSpaceSolid": + if isinstance(clipping, ifcopenshell.entity_instance): + new = ifcopenshell.util.element.copy(self.file, clipping) + new.FirstOperand = first_operand + first_operand = new + elif clipping["operand_type"] == "IfcHalfSpaceSolid": matrix = clipping["matrix"] second_operand = self.file.createIfcHalfSpaceSolid( self.file.createIfcPlane( @@ -113,7 +117,7 @@ class Usecase: ), False, ) - first_operand = self.file.create_entity(clipping["type"], "DIFFERENCE", first_operand, second_operand) + first_operand = self.file.create_entity(clipping["type"], "DIFFERENCE", first_operand, second_operand) return first_operand def convert_si_to_unit(self, co):