From 68fd0c0cf589fb769db929922ad8e45ac2fb186f Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Thu, 14 Oct 2021 18:47:48 +1100 Subject: [PATCH] Fix bug where you couldn't filter imported subelements without also selecting their parents --- src/blenderbim/blenderbim/bim/import_ifc.py | 2 ++ src/blenderbim/blenderbim/bim/module/spatial/operator.py | 2 +- src/ifcopenshell-python/ifcopenshell/api/root/copy_class.py | 3 +++ src/ifcopenshell-python/test/api/root/test_copy_class.py | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/blenderbim/blenderbim/bim/import_ifc.py b/src/blenderbim/blenderbim/bim/import_ifc.py index 5866ccc992..e9d814449c 100644 --- a/src/blenderbim/blenderbim/bim/import_ifc.py +++ b/src/blenderbim/blenderbim/bim/import_ifc.py @@ -1042,6 +1042,8 @@ class IfcImporter: def create_aggregate_collections(self): if self.ifc_import_settings.has_filter: rel_aggregates = [e.IsDecomposedBy[0] for e in self.elements if e.IsDecomposedBy] + rel_aggregates += [e.Decomposes[0] for e in self.elements if e.Decomposes] + rel_aggregates = set(rel_aggregates) else: rel_aggregates = [a for a in self.file.by_type("IfcRelAggregates") if a.RelatingObject.is_a("IfcElement")] diff --git a/src/blenderbim/blenderbim/bim/module/spatial/operator.py b/src/blenderbim/blenderbim/bim/module/spatial/operator.py index f783ebba33..250d5cea34 100644 --- a/src/blenderbim/blenderbim/bim/module/spatial/operator.py +++ b/src/blenderbim/blenderbim/bim/module/spatial/operator.py @@ -104,7 +104,7 @@ class CopyToContainer(bpy.types.Operator): self.file = IfcStore.get_file() objects = list(bpy.data.objects.get(self.obj, context.selected_objects)) sprops = context.scene.BIMSpatialProperties - container_ids = [c.ifc_definition_id for c in sprops.spatial_elements if c.is_selected] + container_ids = [c.ifc_definition_id for c in sprops.containers if c.is_selected] for obj in objects: container = ifcopenshell.util.element.get_container( self.file.by_id(obj.BIMObjectProperties.ifc_definition_id) diff --git a/src/ifcopenshell-python/ifcopenshell/api/root/copy_class.py b/src/ifcopenshell-python/ifcopenshell/api/root/copy_class.py index db85ff5efc..2a1fdf1d03 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/root/copy_class.py +++ b/src/ifcopenshell-python/ifcopenshell/api/root/copy_class.py @@ -54,3 +54,6 @@ class Usecase: if not element.is_a("IfcProduct") or not element.ObjectPlacement: return element.ObjectPlacement = ifcopenshell.util.element.copy(self.file, element.ObjectPlacement) + element.ObjectPlacement.RelativePlacement = ifcopenshell.util.element.copy_deep( + self.file, element.ObjectPlacement.RelativePlacement + ) diff --git a/src/ifcopenshell-python/test/api/root/test_copy_class.py b/src/ifcopenshell-python/test/api/root/test_copy_class.py index 728faae499..e96be46a5a 100644 --- a/src/ifcopenshell-python/test/api/root/test_copy_class.py +++ b/src/ifcopenshell-python/test/api/root/test_copy_class.py @@ -23,6 +23,7 @@ class TestCopyClass(test.bootstrap.IFC4): new = ifcopenshell.api.run("root.copy_class", self.file, product=element) assert subelement.ObjectPlacement.PlacementRelTo == element.ObjectPlacement assert subelement.ObjectPlacement.PlacementRelTo != new.ObjectPlacement + assert element.ObjectPlacement.RelativePlacement != new.ObjectPlacement.RelativePlacement def test_copying_psets_so_changing_properties_of_the_new_element_does_not_affect_the_old(self): element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")