diff --git a/src/blenderbim/test/bim/feature/aggregate.feature b/src/blenderbim/test/bim/feature/aggregate.feature index 7e6e498f56..bf75754b36 100644 --- a/src/blenderbim/test/bim/feature/aggregate.feature +++ b/src/blenderbim/test/bim/feature/aggregate.feature @@ -22,9 +22,7 @@ Scenario: Assign object And I press "bim.enable_editing_aggregate" And the variable "relating_object" is "tool.Ifc.get().by_type('IfcSite')[0].id()" When I press "bim.aggregate_assign_object(relating_object={relating_object})" - Then the object "IfcSite/My Site" is in the collection "IfcSite/My Site" - And the object "IfcBuildingStorey/My Storey" is in the collection "IfcBuildingStorey/My Storey" - And the collection "IfcBuildingStorey/My Storey" is in the collection "IfcSite/My Site" + Then the object "IfcBuildingStorey/My Storey" is aggregated by object "IfcSite/My Site" Scenario: Unassign object Given an empty IFC project @@ -34,29 +32,7 @@ Scenario: Unassign object And I press "bim.aggregate_assign_object(relating_object={relating_object})" And the object "IfcBuildingStorey/My Storey" is selected When I press "bim.aggregate_unassign_object" - Then the object "IfcSite/My Site" is in the collection "IfcSite/My Site" - And the object "IfcBuildingStorey/My Storey" is in the collection "IfcBuildingStorey/My Storey" - And the collection "IfcBuildingStorey/My Storey" is in the collection "IfcProject/My Project" - -Scenario: Unassign object - multiple objects are contained again to their indirect container - Given an empty IFC project - And I add a cube - And the object "Cube" is selected - And I set "scene.BIMRootProperties.ifc_product" to "IfcElement" - And I set "scene.BIMRootProperties.ifc_class" to "IfcMember" - And I press "bim.assign_class" - And I add a cube - And the object "Cube" is selected - And I set "scene.BIMRootProperties.ifc_class" to "IfcCovering" - And I press "bim.assign_class" - And the object "IfcMember/Cube" is selected - And additionally the object "IfcCovering/Cube" is selected - And I press "bim.add_aggregate(ifc_class='IfcWall')" - And the object "IfcMember/Cube" is selected - And additionally the object "IfcCovering/Cube" is selected - When I press "bim.aggregate_unassign_object" - Then the object "IfcMember/Cube" is in the collection "IfcBuildingStorey/My Storey" - And the object "IfcCovering/Cube" is in the collection "IfcBuildingStorey/My Storey" + Then the object "IfcBuildingStorey/My Storey" has no aggregate Scenario: Add aggregate Given an empty IFC project @@ -67,23 +43,9 @@ Scenario: Add aggregate And I press "bim.assign_class" And the object "IfcWall/Cube" is selected When I press "bim.add_aggregate" - Then the object "IfcWall/Cube" is in the collection "IfcElementAssembly/Assembly" - And the object "IfcElementAssembly/Assembly" is in the collection "IfcElementAssembly/Assembly" - And the collection "IfcElementAssembly/Assembly" is in the collection "IfcBuildingStorey/My Storey" - -Scenario: Add aggregate - with the aggregate inheriting the existing spatial collection - Given an empty IFC project - And I add a cube - And the object "Cube" is selected - And I set "scene.BIMRootProperties.ifc_product" to "IfcElement" - And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" - And I press "bim.assign_class" - And the object "IfcWall/Cube" is placed in the collection "IfcBuildingStorey/My Storey" - And the object "IfcWall/Cube" is selected - When I press "bim.add_aggregate" - Then the object "IfcWall/Cube" is in the collection "IfcElementAssembly/Assembly" - And the object "IfcElementAssembly/Assembly" is in the collection "IfcElementAssembly/Assembly" - And the collection "IfcElementAssembly/Assembly" is in the collection "IfcBuildingStorey/My Storey" + Then the object "IfcElementAssembly/Default_Name" exists + And the object "IfcWall/Cube" is aggregated by object "IfcElementAssembly/Default_Name" + And the object "IfcElementAssembly/Default_Name" is contained in object "IfcBuildingStorey/My Storey" Scenario: Add aggregate - add a nested aggregate Given an empty IFC project @@ -92,15 +54,15 @@ Scenario: Add aggregate - add a nested aggregate And I set "scene.BIMRootProperties.ifc_product" to "IfcElement" And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" And I press "bim.assign_class" - And the object "IfcWall/Cube" is placed in the collection "IfcBuildingStorey/My Storey" And the object "IfcWall/Cube" is selected When I press "bim.add_aggregate" And the object "IfcWall/Cube" is selected - And I press "bim.add_aggregate" - Then the object "IfcWall/Cube" is in the collection "IfcElementAssembly/Assembly.001" - And the object "IfcElementAssembly/Assembly.001" is in the collection "IfcElementAssembly/Assembly.001" - And the collection "IfcElementAssembly/Assembly.001" is in the collection "IfcElementAssembly/Assembly" - And the collection "IfcElementAssembly/Assembly" is in the collection "IfcBuildingStorey/My Storey" + And I press "bim.add_aggregate(aggregate_name='Default_Name2')" + Then the object "IfcElementAssembly/Default_Name" exists + And the object "IfcElementAssembly/Default_Name" is contained in object "IfcBuildingStorey/My Storey" + And the object "IfcElementAssembly/Default_Name2" exists + And the object "IfcWall/Cube" is aggregated by object "IfcElementAssembly/Default_Name2" + And the object "IfcElementAssembly/Default_Name2" is aggregated by object "IfcElementAssembly/Default_Name" Scenario: Add aggregate - add multiple elements to a custom aggregate class Given an empty IFC project @@ -115,8 +77,7 @@ Scenario: Add aggregate - add multiple elements to a custom aggregate class And I press "bim.assign_class" And the object "IfcMember/Cube" is selected And additionally the object "IfcCovering/Cube" is selected - When I press "bim.add_aggregate(ifc_class='IfcWall')" - Then the object "IfcMember/Cube" is in the collection "IfcWall/Assembly" - And the object "IfcCovering/Cube" is in the collection "IfcWall/Assembly" - And the object "IfcWall/Assembly" is in the collection "IfcWall/Assembly" - And the collection "IfcWall/Assembly" is in the collection "IfcBuildingStorey/My Storey" + When I press "bim.add_aggregate(ifc_class='IfcWall', aggregate_name='Assembly')" + Then the object "IfcMember/Cube" is aggregated by object "IfcWall/Assembly" + And the object "IfcCovering/Cube" is aggregated by object "IfcWall/Assembly" + And the object "IfcWall/Assembly" is contained in object "IfcBuildingStorey/My Storey" diff --git a/src/blenderbim/test/bim/feature/geometry.feature b/src/blenderbim/test/bim/feature/geometry.feature index 663544196d..46f5541be1 100644 --- a/src/blenderbim/test/bim/feature/geometry.feature +++ b/src/blenderbim/test/bim/feature/geometry.feature @@ -433,18 +433,14 @@ Scenario: Override duplicate move - copying an aggregate And I set "scene.BIMRootProperties.ifc_class" to "IfcWall" And I press "bim.assign_class" And the object "IfcWall/Cube" is selected - When I press "bim.add_aggregate" - Then the object "IfcWall/Cube" is in the collection "IfcElementAssembly/Assembly" - And the object "IfcElementAssembly/Assembly" is in the collection "IfcElementAssembly/Assembly" - And the collection "IfcElementAssembly/Assembly" is in the collection "IfcBuildingStorey/My Storey" + When I press "bim.add_aggregate(aggregate_name='Assembly')" When the object "IfcWall/Cube" is selected And additionally the object "IfcElementAssembly/Assembly" is selected When I duplicate the selected objects Then the object "IfcWall/Cube.001" exists - And the object "IfcWall/Cube.001" is in the collection "IfcElementAssembly/Assembly.001" And the object "IfcElementAssembly/Assembly.001" exists - And the object "IfcElementAssembly/Assembly.001" is in the collection "IfcElementAssembly/Assembly.001" - And the collection "IfcElementAssembly/Assembly.001" is in the collection "IfcBuildingStorey/My Storey" + And the object "IfcWall/Cube.001" is aggregated by object "IfcElementAssembly/Assembly.001" + And the object "IfcElementAssembly/Assembly.001" is contained in object "IfcBuildingStorey/My Storey" Scenario: Override duplicate move - copying objects with connection Given an empty IFC project diff --git a/src/blenderbim/test/bim/feature/root.feature b/src/blenderbim/test/bim/feature/root.feature index 602d9fa40a..243902511e 100644 --- a/src/blenderbim/test/bim/feature/root.feature +++ b/src/blenderbim/test/bim/feature/root.feature @@ -88,7 +88,6 @@ Scenario: Assign a spatial class to a cube already in a collection And I press "bim.assign_class" Then the object "IfcSpace/Cube" is an "IfcSpace" And the object "IfcSpace/Cube" is in the collection "IfcSpace/Cube" - And the collection "IfcSpace/Cube" is in the collection "IfcBuildingStorey/My Storey" And the object "IfcSpace/Cube" has a "Tessellation" representation of "Model/Body/MODEL_VIEW" Scenario: Assign a class to a cube in a collection @@ -118,4 +117,3 @@ Scenario: Copy a storey Then the object "IfcBuildingStorey/My Storey" and "IfcBuildingStorey/My Storey.001" are different elements And the object "IfcBuildingStorey/My Storey" is in the collection "IfcBuildingStorey/My Storey" And the object "IfcBuildingStorey/My Storey.001" is in the collection "IfcBuildingStorey/My Storey.001" - And the collection "IfcBuildingStorey/My Storey.001" is in the collection "IfcBuilding/My Building" diff --git a/src/blenderbim/test/bim/test_feature.py b/src/blenderbim/test/bim/test_feature.py index a19da329c7..05b2eb6c8d 100644 --- a/src/blenderbim/test/bim/test_feature.py +++ b/src/blenderbim/test/bim/test_feature.py @@ -868,6 +868,37 @@ def the_object_name_is_contained_in_container_name(name, container_name): assert container.Name == container_name, f'Object "{name}" is in {container}' +@then(parsers.parse('the object "{name}" is contained in object "{container_name}"')) +def the_object_name_is_contained_in_object_container_name(name: str, container_name: str) -> None: + ifc = an_ifc_file_exists() + element = ifc.by_id(the_object_name_exists(name).BIMObjectProperties.ifc_definition_id) + container = ifcopenshell.util.element.get_container(element) + if not container: + assert False, f'Object "{name}" is not in any container' + container_obj = tool.Ifc.get_object(container) + assert container_obj.name == container_name, f'Object "{name}" is in {container_obj}' + + +@then(parsers.parse('the object "{name}" is aggregated by object "{aggregate_name}"')) +def the_object_name_is_aggregated_by_object_aggregate_name(name: str, aggregate_name: str) -> None: + ifc = an_ifc_file_exists() + element = ifc.by_id(the_object_name_exists(name).BIMObjectProperties.ifc_definition_id) + aggregate = ifcopenshell.util.element.get_aggregate(element) + if not aggregate: + assert False, f'Object "{name}" is not aggregated by any element' + aggregate_obj = tool.Ifc.get_object(aggregate) + assert aggregate_obj.name == aggregate_name, f'Object "{name}" is aggregated by {aggregate_obj}' + + +@then(parsers.parse('the object "{name}" has no aggregate')) +def the_object_name_has_no_aggregate(name: str) -> None: + ifc = an_ifc_file_exists() + element = ifc.by_id(the_object_name_exists(name).BIMObjectProperties.ifc_definition_id) + aggregate = ifcopenshell.util.element.get_aggregate(element) + if aggregate: + assert False, f'Object "{name}" is aggregated by element "{aggregate}"' + + @then(parsers.parse('the file "{name}" should contain "{value}"')) def the_file_name_should_contain_value(name, value): name = replace_variables(name)