From 3faaee80ec0a1b01f5e2c20958d3396a0a23c661 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 29 Sep 2023 09:29:25 +0500 Subject: [PATCH] copy_deep to always pass exclude_callback to the recursion It wasn't passing the exclude_callback if attribute of the copied element wasn't a tuple, resulting in duplicated named profiles in case if you'd copy a IfcBooleanClippingResult #3810 For example, how copy_deep of IfcProductDefinitionShape with boolean clipping previously would work: V IfcShapeRepresentation - copied with exlude_callback (part of .Representations[]) V IfcBooleanClippingResult - copied with exlude_callback (part of .Items[]) X IfcExtrudedAreaSolid - copied without exlude_callback becuase it's part of .FirstOperand (not an array) and we have IfcIShapeProfileDef duplicated Case without booleanclippings: V IfcShapeRepresentation - copied with exlude_callback (part of .Representations[]) V IfcExtrudedAreaSolid - copied with exlude_callback, since it's part of .Items[], IfcIShapeProfileDef not duplicated --- src/ifcopenshell-python/ifcopenshell/util/element.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/element.py b/src/ifcopenshell-python/ifcopenshell/util/element.py index ac84cc7046..4852ff067c 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/element.py +++ b/src/ifcopenshell-python/ifcopenshell/util/element.py @@ -1022,7 +1022,13 @@ def copy_deep(ifc_file, element, exclude=None, exclude_callback=None, copied_ent elif exclude_callback and exclude_callback(attribute): pass else: - attribute = copy_deep(ifc_file, attribute, exclude=exclude, copied_entities=copied_entities) + attribute = copy_deep( + ifc_file, + attribute, + exclude=exclude, + copied_entities=copied_entities, + exclude_callback=exclude_callback, + ) elif isinstance(attribute, tuple) and attribute and isinstance(attribute[0], ifcopenshell.entity_instance): if exclude and any([attribute[0].is_a(e) for e in exclude]): pass