From 72ef05594603c6650430e93438e88cbc4d0a50a0 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 27 May 2025 10:38:29 +1000 Subject: [PATCH] Add tests for boundary --- .../bonsai/bim/module/boundary/operator.py | 8 +++++ src/bonsai/pytest.ini | 1 + src/bonsai/test/bim/feature/boundary.feature | 30 +++++++++++++++++++ src/bonsai/test/bim/feature/model.feature | 24 +++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 src/bonsai/test/bim/feature/boundary.feature diff --git a/src/bonsai/bonsai/bim/module/boundary/operator.py b/src/bonsai/bonsai/bim/module/boundary/operator.py index 41d3f4ab4a..d9958a80db 100644 --- a/src/bonsai/bonsai/bim/module/boundary/operator.py +++ b/src/bonsai/bonsai/bim/module/boundary/operator.py @@ -676,6 +676,14 @@ class AddBoundary(bpy.types.Operator, tool.Ifc.Operator): + tool.Ifc.get().by_type("IfcVirtualElement") ) + for building_element in building_elements: + if obj := tool.Ifc.get_object(building_element): + if tool.Ifc.is_moved(obj): + bonsai.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=obj) + + if tool.Ifc.is_moved(space_obj): + bonsai.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=space_obj) + # Don't generate boundaries of building elements that we've already got bounaries for. for boundary in space.BoundedBy: if boundary.RelatedBuildingElement in building_elements: diff --git a/src/bonsai/pytest.ini b/src/bonsai/pytest.ini index 94a75aaa5a..001313dd30 100644 --- a/src/bonsai/pytest.ini +++ b/src/bonsai/pytest.ini @@ -3,6 +3,7 @@ markers = aggregate attribute boolean + boundary brick bsdd classification diff --git a/src/bonsai/test/bim/feature/boundary.feature b/src/bonsai/test/bim/feature/boundary.feature new file mode 100644 index 0000000000..4b42a0bc2e --- /dev/null +++ b/src/bonsai/test/bim/feature/boundary.feature @@ -0,0 +1,30 @@ +@boundary +Feature: Boundary + +Scenario: Add boundary from space + Given an empty IFC project + And I load the demo construction library + And I set "scene.BIMModelProperties.ifc_class" to "IfcWallType" + And the variable "element_type" is "[e for e in {ifc}.by_type('IfcWallType') if e.Name == 'WAL100'][0].id()" + And I set "scene.BIMModelProperties.relating_type_id" to "{element_type}" + And I press "bim.add_occurrence" + And the cursor is at "1.1,0,0" + And I press "bim.add_occurrence" + And the object "IfcWall/Wall.001" is selected + And I press "bim.hotkey(hotkey='S_R')" + And the cursor is at "0,.9,0" + And I press "bim.add_occurrence" + And the cursor is at "-1,0,0" + And I press "bim.add_occurrence" + And the object "IfcWall/Wall.003" is selected + And I press "bim.hotkey(hotkey='S_R')" + And the object "IfcWall/Wall.003" is moved to "0,0,0" + And the cursor is at "0.5,0.5,0" + And I deselect all objects + And I press "bim.generate_space" + When I select the object "IfcSpace/Space" + And I press "bim.add_boundary" + Then the object "IfcRelSpaceBoundary/None" exists + And the object "IfcRelSpaceBoundary/None.001" exists + And the object "IfcRelSpaceBoundary/None.002" exists + And the object "IfcRelSpaceBoundary/None.003" exists diff --git a/src/bonsai/test/bim/feature/model.feature b/src/bonsai/test/bim/feature/model.feature index bcf57acf73..98930639fa 100644 --- a/src/bonsai/test/bim/feature/model.feature +++ b/src/bonsai/test/bim/feature/model.feature @@ -731,3 +731,27 @@ Scenario: Create a MEP bend between intersecting segments at the same location And the object "IfcDuctSegment/Seg2" dimensions are "0.4,0.2,4.5" And the object "IfcDuctFitting/DuctFitting" is at "0.0, 0.5, 1.0" And the object "IfcDuctFitting/DuctFitting" dimensions are "0.7, 0.2, 0.7" + +Scenario: Generate a space from cursor location + Given an empty IFC project + And I load the demo construction library + And I set "scene.BIMModelProperties.ifc_class" to "IfcWallType" + And the variable "element_type" is "[e for e in {ifc}.by_type('IfcWallType') if e.Name == 'WAL100'][0].id()" + And I set "scene.BIMModelProperties.relating_type_id" to "{element_type}" + And I press "bim.add_occurrence" + And the cursor is at "1.1,0,0" + And I press "bim.add_occurrence" + And the object "IfcWall/Wall.001" is selected + And I press "bim.hotkey(hotkey='S_R')" + And the cursor is at "0,.9,0" + And I press "bim.add_occurrence" + And the cursor is at "-1,0,0" + And I press "bim.add_occurrence" + And the object "IfcWall/Wall.003" is selected + And I press "bim.hotkey(hotkey='S_R')" + And the object "IfcWall/Wall.003" is moved to "0,0,0" + When the cursor is at "0.5,0.5,0" + And I deselect all objects + And I press "bim.generate_space" + Then the object "IfcSpace/Space" exists + And the object "IfcSpace/Space" dimensions are "1,0.8,3"