From f529bc37ee09548a3018112e34b5a70a2b600bcd Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 29 Nov 2021 20:25:51 +1100 Subject: [PATCH] Fix bug where selecting type occurrences did not work --- .../blenderbim/bim/module/type/operator.py | 7 +++---- src/blenderbim/test/bim/feature/type.feature | 17 +++++++++++++++++ src/blenderbim/test/bim/test_feature.py | 6 ++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/type/operator.py b/src/blenderbim/blenderbim/bim/module/type/operator.py index 68acc39b05..bef163ce90 100644 --- a/src/blenderbim/blenderbim/bim/module/type/operator.py +++ b/src/blenderbim/blenderbim/bim/module/type/operator.py @@ -161,9 +161,8 @@ class SelectTypeObjects(bpy.types.Operator): def execute(self, context): self.file = IfcStore.get_file() relating_type = bpy.data.objects.get(self.relating_type) if self.relating_type else context.active_object - oprops = relating_type.BIMObjectProperties - related_objects = Data.types[oprops.ifc_definition_id] - for obj in context.visible_objects: - if obj.BIMObjectProperties.ifc_definition_id in related_objects: + for element in ifcopenshell.util.element.get_types(tool.Ifc.get_entity(relating_type)): + obj = tool.Ifc.get_object(element) + if obj: obj.select_set(True) return {"FINISHED"} diff --git a/src/blenderbim/test/bim/feature/type.feature b/src/blenderbim/test/bim/feature/type.feature index d258a077a1..2161090f26 100644 --- a/src/blenderbim/test/bim/feature/type.feature +++ b/src/blenderbim/test/bim/feature/type.feature @@ -85,3 +85,20 @@ Scenario: Assign type - assign to a type with a material profile set When the variable "type" is "{ifc}.by_type('IfcWallType')[0].id()" And I press "bim.assign_type(relating_type={type}, related_object='IfcWall/Cube')" Then the object "IfcWall/Cube" has a "SweptSolid" representation of "Model/Body/MODEL_VIEW" + +Scenario: Select type objects + Given an empty IFC project + And I add a cube + And the object "Cube" is selected + And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" + And I press "bim.assign_class" + And I add an empty + And the object "Empty" is selected + And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType" + And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType" + And I press "bim.assign_class" + And the variable "type" is "{ifc}.by_type('IfcWallType')[0].id()" + And I press "bim.assign_type(relating_type={type}, related_object='IfcWall/Cube')" + When the object "IfcWallType/Empty" is selected + And I press "bim.select_type_objects" + Then the object "IfcWall/Cube" is selected diff --git a/src/blenderbim/test/bim/test_feature.py b/src/blenderbim/test/bim/test_feature.py index 82813b2e7b..4b855b7308 100644 --- a/src/blenderbim/test/bim/test_feature.py +++ b/src/blenderbim/test/bim/test_feature.py @@ -153,6 +153,12 @@ def the_object_name_is_selected(name): additionally_the_object_name_is_selected(name) +@then(parsers.parse('the object "{name}" is selected')) +def then_the_object_name_is_selected(name): + obj = the_object_name_exists(name) + assert obj in bpy.context.selected_objects + + @given(parsers.parse('the object "{name}" is moved to "{location}"')) @when(parsers.parse('the object "{name}" is moved to "{location}"')) def the_object_name_is_moved_to_location(name, location):