diff --git a/src/blenderbim/blenderbim/bim/module/search/operator.py b/src/blenderbim/blenderbim/bim/module/search/operator.py index a1d8af4434..8deaecd224 100644 --- a/src/blenderbim/blenderbim/bim/module/search/operator.py +++ b/src/blenderbim/blenderbim/bim/module/search/operator.py @@ -470,7 +470,6 @@ class ActivateIfcBuildingStoreyFilter(Operator): row.operator("bim.toggle_filter_selection", text="Select All").action = "SELECT" row.operator("bim.toggle_filter_selection", text="Deselect All").action = "DESELECT" - class UnhideAllElements(Operator): """Filter model elements based on selection""" @@ -669,9 +668,8 @@ class AddToIfcGroup(Operator): group = ifcopenshell.api.run("group.add_group", self.file, **{"Name": self.group_name}) objects = Selector.parse(self.file, selector_query_syntax) - for obj in objects: - ifcopenshell.api.run("group.assign_group", self.file, **{"product": obj, "group": group}) - + + ifcopenshell.api.run("group.assign_group", self.file, **{"product": objects, "group": group}) Data.load(IfcStore.get_file()) return {"FINISHED"} diff --git a/src/blenderbim/test/bim/feature/search.feature b/src/blenderbim/test/bim/feature/search.feature new file mode 100644 index 0000000000..76217d6f98 --- /dev/null +++ b/src/blenderbim/test/bim/feature/search.feature @@ -0,0 +1,16 @@ +@root +Feature: Search + +Scenario: Select all walls + Given an empty IFC project + And I add a cube + When the object "Cube" is selected + And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" + And I press "bim.assign_class" + And I add a new group to IfcSelector + And I add a new query to IfcSelector + And I set "scene.IfcSelectorProperties.groups[0].queries[0].active_option" to "IFC Class" + And I set "scene.IfcSelectorProperties.groups[0].queries[0].active_option" to "124: IfcWall" + And I press 'bim.filter_model_elements' + Then bpy.context.selected_objects should contain "Cube" + diff --git a/src/blenderbim/test/bim/test_feature.py b/src/blenderbim/test/bim/test_feature.py index 4cd6dbcd5a..b56785404a 100644 --- a/src/blenderbim/test/bim/test_feature.py +++ b/src/blenderbim/test/bim/test_feature.py @@ -98,6 +98,15 @@ def i_add_a_sun(): def i_add_a_material(): bpy.context.active_object.active_material = bpy.data.materials.new("Material") +@given("I add a new group to IfcSelector") +@when("I add a new group to IfcSelector") +def i_add_a_new_collection_item(): + bpy.data.scenes["Scene"].IfcSelectorProperties.groups.add() + +@given("I add a new query to IfcSelector") +@when("I add a new query to IfcSelector") +def i_add_a_new_collection_item(): + bpy.data.scenes["Scene"].IfcSelectorProperties.groups[0].queries.add() @given(parsers.parse('the material "{name}" colour is set to "{colour}"')) @when(parsers.parse('the material "{name}" colour is set to "{colour}"')) diff --git a/src/ifcopenshell-python/ifcopenshell/api/group/assign_group.py b/src/ifcopenshell-python/ifcopenshell/api/group/assign_group.py index b8cdea2d9f..ed252a1878 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/group/assign_group.py +++ b/src/ifcopenshell-python/ifcopenshell/api/group/assign_group.py @@ -37,7 +37,7 @@ class Usecase: **{ "GlobalId": ifcopenshell.guid.new(), "OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", self.file), - "RelatedObjects": [self.settings["product"]], + "RelatedObjects": self.settings["product"], "RelatingGroup": self.settings["group"], } )