From acdc40fb4107581aff9a0c5badc834701214d0d3 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 12 Mar 2025 23:04:41 +1100 Subject: [PATCH] See #1227. Reimplement extending walls to another wall --- .../bonsai/bim/module/model/__init__.py | 1 + src/bonsai/bonsai/bim/module/model/wall.py | 40 +++++ .../bonsai/bim/module/model/workspace.py | 8 +- src/bonsai/test/bim/feature/geometry.feature | 15 +- src/bonsai/test/bim/feature/model.feature | 160 +++++++----------- src/bonsai/test/bim/test_feature.py | 20 +-- 6 files changed, 122 insertions(+), 122 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/model/__init__.py b/src/bonsai/bonsai/bim/module/model/__init__.py index 7eed142ee2..e3299578e2 100644 --- a/src/bonsai/bonsai/bim/module/model/__init__.py +++ b/src/bonsai/bonsai/bim/module/model/__init__.py @@ -73,6 +73,7 @@ classes = ( wall.ChangeLayerLength, wall.DrawPolylineWall, wall.ExtendWallsToUnderside, + wall.ExtendWallsToWall, wall.FlipWall, wall.MergeWall, wall.RecalculateWall, diff --git a/src/bonsai/bonsai/bim/module/model/wall.py b/src/bonsai/bonsai/bim/module/model/wall.py index eef3487217..6c74184083 100644 --- a/src/bonsai/bonsai/bim/module/model/wall.py +++ b/src/bonsai/bonsai/bim/module/model/wall.py @@ -78,6 +78,46 @@ class ExtendWallsToUnderside(bpy.types.Operator, tool.Ifc.Operator): self.report({"ERROR"}, "Please select at least one LAYER2 element and an active element") +class ExtendWallsToWall(bpy.types.Operator, tool.Ifc.Operator): + bl_idname = "bim.extend_walls_to_wall" + bl_label = "Extend Walls To Wall" + bl_description = "Extend and trim selected walls to another wall" + bl_options = {"REGISTER", "UNDO"} + + def _execute(self, context): + target_obj = None + objs = [] + if ( + (obj := tool.Blender.get_active_object(is_selected=True)) + and (element := tool.Ifc.get_entity(obj)) + and tool.Model.get_usage_type(element) == "LAYER2" + ): + target_obj = obj + for obj in tool.Blender.get_selected_objects(include_active=False): + if ( + obj != target_obj + and (element := tool.Ifc.get_entity(obj)) + and tool.Model.get_usage_type(element) == "LAYER2" + ): + objs.append(obj) + if target_obj and objs: + if tool.Ifc.is_moved(target_obj): + bonsai.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=target_obj) + joiner = DumbWallJoiner() + target_element = tool.Ifc.get_entity(target_obj) + for obj in objs: + if tool.Ifc.is_moved(obj): + bonsai.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=obj) + element = tool.Ifc.get_entity(obj) + ifcopenshell.api.geometry.connect_wall( + tool.Ifc.get(), wall1=element, wall2=target_element, is_atpath=True + ) + joiner.recreate_wall(element, obj) + joiner.recreate_wall(target_element, target_obj) + else: + self.report({"ERROR"}, "Please select at least one LAYER2 element and one active LAYER2 element") + + class AlignWall(bpy.types.Operator): bl_idname = "bim.align_wall" bl_label = "Align Wall" diff --git a/src/bonsai/bonsai/bim/module/model/workspace.py b/src/bonsai/bonsai/bim/module/model/workspace.py index 21e1dce148..cb1cdde985 100644 --- a/src/bonsai/bonsai/bim/module/model/workspace.py +++ b/src/bonsai/bonsai/bim/module/model/workspace.py @@ -1217,13 +1217,7 @@ class Hotkey(bpy.types.Operator, tool.Ifc.Operator): bpy.ops.bim.extend_profile(join_type="T") elif self.active_material_usage == "LAYER2": - # Extend LAYER2s to LAYER2 - [o.select_set(False) for o in selected_usages.get("LAYER3", [])] - [o.select_set(False) for o in selected_usages.get("PROFILE", [])] - try: - core.join_walls_TZ(tool.Ifc, tool.Blender, tool.Geometry, DumbWallJoiner(), tool.Model) - except core.RequireAtLeastTwoLayeredElements as e: - self.report({"ERROR"}, str(e)) + bpy.ops.bim.extend_walls_to_wall() elif self.active_material_usage == "PROFILE": # Extend PROFILEs to PROFILE diff --git a/src/bonsai/test/bim/feature/geometry.feature b/src/bonsai/test/bim/feature/geometry.feature index 16dddb4a39..7d3459fdc7 100644 --- a/src/bonsai/test/bim/feature/geometry.feature +++ b/src/bonsai/test/bim/feature/geometry.feature @@ -453,14 +453,14 @@ Scenario: Override duplicate move - copying walls with mitre joint 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.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the cursor is at "0.5,0,0" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcWall/Wall.001" is selected And additionally the object "IfcWall/Wall" is selected - When I press "bim.hotkey(hotkey='S_Y')" - Then the object "IfcWall/Wall" dimensions are "0.5,0.1,3" - And the object "IfcWall/Wall" bottom left corner is at "0.5,0,0" + When I press "bim.hotkey(hotkey='S_T')" + Then the object "IfcWall/Wall" dimensions are "0.6,0.1,3" + And the object "IfcWall/Wall" bottom left corner is at "0,0,0" And the object "IfcWall/Wall.001" dimensions are "1.1,0.1,3" And the object "IfcWall/Wall.001" bottom left corner is at "0.5,0.1,0" And the object "IfcWall/Wall.001" top right corner is at "0.6,-1,3" @@ -549,10 +549,11 @@ Scenario: Refresh linked aggregate When I deselect all objects And the object "IfcWall/Wall_01.001" is selected When the object layer length is set to "3" - Then the object "IfcWall/Wall_01.001" dimensions are "3,0.1,3" + # Extra 0.1 due to mitre + Then the object "IfcWall/Wall_01.001" dimensions are "3.1,0.1,3" When I refresh linked aggregate the selected object Then the object "IfcWall/Wall_01" exists - And the object "IfcWall/Wall_01" dimensions are "3,0.1,3" + And the object "IfcWall/Wall_01" dimensions are "3.1,0.1,3" Scenario: Refresh linked aggregate - after deleting an object Given I load the IFC test file "/test/files/linked-aggregates.ifc" diff --git a/src/bonsai/test/bim/feature/model.feature b/src/bonsai/test/bim/feature/model.feature index 04a08c1445..729bd52bd5 100644 --- a/src/bonsai/test/bim/feature/model.feature +++ b/src/bonsai/test/bim/feature/model.feature @@ -83,7 +83,7 @@ Scenario: Extend a wall to the cursor 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.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcWall/Wall" is selected And the cursor is at "2,0,0" When I press "bim.hotkey(hotkey='S_E')" @@ -96,9 +96,9 @@ Scenario: Add a wall perpendicular to an existing wall 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.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the cursor is at "0.5,0,0" - When I press "bim.hotkey(hotkey='S_A')" + When I press "bim.add_occurrence" Then the object "IfcWall/Wall" dimensions are "1,0.1,3" And the object "IfcWall/Wall" bottom left corner is at "0,0,0" And the object "IfcWall/Wall.001" dimensions are "1,0.1,3" @@ -111,9 +111,9 @@ Scenario: Extend one wall to another 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.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the cursor is at "0.5,0,0" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcWall/Wall.001" is moved to "0.5,-1,0" And the object "IfcWall/Wall.001" is selected And additionally the object "IfcWall/Wall" is selected @@ -124,59 +124,23 @@ Scenario: Extend one wall to another And the object "IfcWall/Wall.001" bottom left corner is at "0.5,0,0" And the object "IfcWall/Wall.001" top right corner is at "0.6,-2,3" -Scenario: Join two walls with a butt joint - first wall has priority - 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.hotkey(hotkey='S_A')" - And the cursor is at "0.5,0,0" - And I press "bim.hotkey(hotkey='S_A')" - And the object "IfcWall/Wall.001" is selected - And additionally the object "IfcWall/Wall" is selected - When I press "bim.hotkey(hotkey='S_T')" - Then the object "IfcWall/Wall" dimensions are "0.4,0.1,3" - And the object "IfcWall/Wall" bottom left corner is at "0.6,0,0" - And the object "IfcWall/Wall.001" dimensions are "1.1,0.1,3" - And the object "IfcWall/Wall.001" bottom left corner is at "0.5,0.1,0" - And the object "IfcWall/Wall.001" top right corner is at "0.6,-1,3" - -Scenario: Join two walls with a butt joint - second wall has priority - 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.hotkey(hotkey='S_A')" - And the cursor is at "0.5,0,0" - And I press "bim.hotkey(hotkey='S_A')" - And the object "IfcWall/Wall" is selected - And additionally the object "IfcWall/Wall.001" is selected - When I press "bim.hotkey(hotkey='S_T')" - Then the object "IfcWall/Wall" dimensions are "0.5,0.1,3" - And the object "IfcWall/Wall" bottom left corner is at "0.5,0,0" - And the object "IfcWall/Wall.001" dimensions are "1,0.1,3" - And the object "IfcWall/Wall.001" bottom left corner is at "0.5,0,0" - And the object "IfcWall/Wall.001" top right corner is at "0.6,-1,3" - Scenario: Join two walls with a mitre joint 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.hotkey(hotkey='S_A')" - And the cursor is at "0.5,0,0" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" + And the cursor is at "0.7,0,0" + And I press "bim.add_occurrence" And the object "IfcWall/Wall.001" is selected And additionally the object "IfcWall/Wall" is selected - When I press "bim.hotkey(hotkey='S_Y')" - Then the object "IfcWall/Wall" dimensions are "0.5,0.1,3" - And the object "IfcWall/Wall" bottom left corner is at "0.5,0,0" + When I press "bim.hotkey(hotkey='S_T')" + Then the object "IfcWall/Wall" dimensions are "0.8,0.1,3" + And the object "IfcWall/Wall" bottom left corner is at "0.0,0,0" And the object "IfcWall/Wall.001" dimensions are "1.1,0.1,3" - And the object "IfcWall/Wall.001" bottom left corner is at "0.5,0.1,0" - And the object "IfcWall/Wall.001" top right corner is at "0.6,-1,3" + And the object "IfcWall/Wall.001" bottom left corner is at "0.7,0.1,0" + And the object "IfcWall/Wall.001" top right corner is at "0.8,-1,3" Scenario: Change the height of a wall Given an empty IFC project @@ -184,7 +148,7 @@ Scenario: Change the height of a wall 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.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcWall/Wall" is selected And I set "scene.BIMModelProperties.extrusion_depth" to "2.0" When I press "bim.change_extrusion_depth(depth=2.0)" @@ -196,7 +160,7 @@ Scenario: Change the length of a wall 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.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcWall/Wall" is selected And I set "scene.BIMModelProperties.length" to "2.0" When I press "bim.change_layer_length(length=2.0)" @@ -208,12 +172,12 @@ Scenario: Flip a wall 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.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcWall/Wall" is selected When I press "bim.hotkey(hotkey='S_F')" Then the object "IfcWall/Wall" dimensions are "1,0.1,3" - And the object "IfcWall/Wall" bottom left corner is at "1,0,0" - And the object "IfcWall/Wall" top right corner is at "0,-0.1,3" + And the object "IfcWall/Wall" bottom left corner is at "0,0,0" + And the object "IfcWall/Wall" top right corner is at "1,0.1,3" Scenario: Split a wall Given an empty IFC project @@ -221,7 +185,7 @@ Scenario: Split a wall 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.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcWall/Wall" is selected And the cursor is at "0.5,0,0" When I press "bim.hotkey(hotkey='S_K')" @@ -240,7 +204,7 @@ Scenario: Rotate a wall by 90 degrees 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.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcWall/Wall" is selected When I press "bim.hotkey(hotkey='S_R')" Then the object "IfcWall/Wall" dimensions are "1,0.1,3" @@ -253,7 +217,7 @@ Scenario: Regenerate a wall - after doing nothing interesting 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.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcWall/Wall" is selected When I press "bim.hotkey(hotkey='S_G')" Then the object "IfcWall/Wall" is an "IfcWall" @@ -266,11 +230,11 @@ Scenario: Add a slab And I set "scene.BIMModelProperties.ifc_class" to "IfcSlabType" And the variable "element_type" is "[e for e in {ifc}.by_type('IfcSlabType') if e.Name == 'FLR200'][0].id()" And I set "scene.BIMModelProperties.relating_type_id" to "{element_type}" - When I press "bim.hotkey(hotkey='S_A')" + When I press "bim.add_occurrence" Then the object "IfcSlab/Slab" is an "IfcSlab" And the object "IfcSlab/Slab" dimensions are "1,1,0.2" - And the object "IfcSlab/Slab" bottom left corner is at "0,0,-0.2" - And the object "IfcSlab/Slab" top right corner is at "1,1,0" + And the object "IfcSlab/Slab" bottom left corner is at "0,0,0" + And the object "IfcSlab/Slab" top right corner is at "1,1,0.2" Scenario: Enable editing a slab profile Given an empty IFC project @@ -278,12 +242,12 @@ Scenario: Enable editing a slab profile And I set "scene.BIMModelProperties.ifc_class" to "IfcSlabType" And the variable "element_type" is "[e for e in {ifc}.by_type('IfcSlabType') if e.Name == 'FLR200'][0].id()" And I set "scene.BIMModelProperties.relating_type_id" to "{element_type}" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcSlab/Slab" is selected When I press "bim.hotkey(hotkey='S_E')" Then the object "IfcSlab/Slab" dimensions are "1,1,0" - And the object "IfcSlab/Slab" bottom left corner is at "0,0,-0.2" - And the object "IfcSlab/Slab" top right corner is at "1,1,-0.2" + And the object "IfcSlab/Slab" bottom left corner is at "0,0,0" + And the object "IfcSlab/Slab" top right corner is at "1,1,0" Scenario: Disable editing a slab profile Given an empty IFC project @@ -291,13 +255,13 @@ Scenario: Disable editing a slab profile And I set "scene.BIMModelProperties.ifc_class" to "IfcSlabType" And the variable "element_type" is "[e for e in {ifc}.by_type('IfcSlabType') if e.Name == 'FLR200'][0].id()" And I set "scene.BIMModelProperties.relating_type_id" to "{element_type}" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcSlab/Slab" is selected And I press "bim.hotkey(hotkey='S_E')" When I press "bim.disable_editing_extrusion_profile" Then the object "IfcSlab/Slab" dimensions are "1,1,0.2" - And the object "IfcSlab/Slab" bottom left corner is at "0,0,-0.2" - And the object "IfcSlab/Slab" top right corner is at "1,1,0" + And the object "IfcSlab/Slab" bottom left corner is at "0,0,0" + And the object "IfcSlab/Slab" top right corner is at "1,1,0.2" Scenario: Edit a slab profile Given an empty IFC project @@ -305,13 +269,13 @@ Scenario: Edit a slab profile And I set "scene.BIMModelProperties.ifc_class" to "IfcSlabType" And the variable "element_type" is "[e for e in {ifc}.by_type('IfcSlabType') if e.Name == 'FLR200'][0].id()" And I set "scene.BIMModelProperties.relating_type_id" to "{element_type}" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcSlab/Slab" is selected And I press "bim.hotkey(hotkey='S_E')" When I press "bim.edit_extrusion_profile" Then the object "IfcSlab/Slab" dimensions are "1,1,0.2" - And the object "IfcSlab/Slab" bottom left corner is at "0,0,-0.2" - And the object "IfcSlab/Slab" top right corner is at "1,1,0" + And the object "IfcSlab/Slab" bottom left corner is at "0,0,0" + And the object "IfcSlab/Slab" top right corner is at "1,1,0.2" Scenario: Add a beam Given an empty IFC project @@ -319,7 +283,7 @@ Scenario: Add a beam And I set "scene.BIMModelProperties.ifc_class" to "IfcBeamType" And the variable "element_type" is "[e for e in {ifc}.by_type('IfcBeamType') if e.Name == 'B1'][0].id()" And I set "scene.BIMModelProperties.relating_type_id" to "{element_type}" - When I press "bim.hotkey(hotkey='S_A')" + When I press "bim.add_occurrence" Then the object "IfcBeam/Beam" is an "IfcBeam" And the object "IfcBeam/Beam" dimensions are "0.1,0.2,3" And the object "IfcBeam/Beam" bottom left corner is at "0,-0.05,-0.1" @@ -331,7 +295,7 @@ Scenario: Extend a beam to the cursor And I set "scene.BIMModelProperties.ifc_class" to "IfcBeamType" And the variable "element_type" is "[e for e in {ifc}.by_type('IfcBeamType') if e.Name == 'B1'][0].id()" And I set "scene.BIMModelProperties.relating_type_id" to "{element_type}" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcBeam/Beam" is selected And the cursor is at "2,0,0" When I press "bim.hotkey(hotkey='S_E')" @@ -344,9 +308,9 @@ Scenario: Extend one beam to another And I set "scene.BIMModelProperties.ifc_class" to "IfcBeamType" And the variable "element_type" is "[e for e in {ifc}.by_type('IfcBeamType') if e.Name == 'B1'][0].id()" And I set "scene.BIMModelProperties.relating_type_id" to "{element_type}" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the cursor is at "1,1,0" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcBeam/Beam.001" is selected And I press "bim.hotkey(hotkey='S_R')" And the object "IfcBeam/Beam.001" is selected @@ -365,9 +329,9 @@ Scenario: Join two beams with a butt joint - first beam has priority And I set "scene.BIMModelProperties.ifc_class" to "IfcBeamType" And the variable "element_type" is "[e for e in {ifc}.by_type('IfcBeamType') if e.Name == 'B1'][0].id()" And I set "scene.BIMModelProperties.relating_type_id" to "{element_type}" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the cursor is at "1,1,0" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcBeam/Beam.001" is selected And I press "bim.hotkey(hotkey='S_R')" And the object "IfcBeam/Beam.001" is selected @@ -386,9 +350,9 @@ Scenario: Join two beams with a butt joint - second beam has priority And I set "scene.BIMModelProperties.ifc_class" to "IfcBeamType" And the variable "element_type" is "[e for e in {ifc}.by_type('IfcBeamType') if e.Name == 'B1'][0].id()" And I set "scene.BIMModelProperties.relating_type_id" to "{element_type}" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the cursor is at "1,1,0" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcBeam/Beam.001" is selected And I press "bim.hotkey(hotkey='S_R')" And the object "IfcBeam/Beam" is selected @@ -407,9 +371,9 @@ Scenario: Join two beams with a mitre joint And I set "scene.BIMModelProperties.ifc_class" to "IfcBeamType" And the variable "element_type" is "[e for e in {ifc}.by_type('IfcBeamType') if e.Name == 'B1'][0].id()" And I set "scene.BIMModelProperties.relating_type_id" to "{element_type}" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the cursor is at "1,1,0" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcBeam/Beam.001" is selected And I press "bim.hotkey(hotkey='S_R')" And the object "IfcBeam/Beam" is selected @@ -428,7 +392,7 @@ Scenario: Change the length of a beam And I set "scene.BIMModelProperties.ifc_class" to "IfcBeamType" And the variable "element_type" is "[e for e in {ifc}.by_type('IfcBeamType') if e.Name == 'B1'][0].id()" And I set "scene.BIMModelProperties.relating_type_id" to "{element_type}" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcBeam/Beam" is selected And I set "scene.BIMModelProperties.extrusion_depth" to "2.0" When I press "bim.change_profile_depth(depth=2.0)" @@ -440,7 +404,7 @@ Scenario: Rotate a beam by 90 degrees And I set "scene.BIMModelProperties.ifc_class" to "IfcBeamType" And the variable "element_type" is "[e for e in {ifc}.by_type('IfcBeamType') if e.Name == 'B1'][0].id()" And I set "scene.BIMModelProperties.relating_type_id" to "{element_type}" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcBeam/Beam" is selected When I press "bim.hotkey(hotkey='S_R')" Then the object "IfcBeam/Beam" dimensions are "0.1,0.2,3" @@ -453,7 +417,7 @@ Scenario: Regenerate a beam - after doing nothing interesting And I set "scene.BIMModelProperties.ifc_class" to "IfcBeamType" And the variable "element_type" is "[e for e in {ifc}.by_type('IfcBeamType') if e.Name == 'B1'][0].id()" And I set "scene.BIMModelProperties.relating_type_id" to "{element_type}" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcBeam/Beam" is selected When I press "bim.hotkey(hotkey='S_G')" Then the object "IfcBeam/Beam" dimensions are "0.1,0.2,3" @@ -464,13 +428,13 @@ Scenario: Undo test - create a wall and couple windows and undo the last window Given an empty IFC project And I load the demo construction library And I set "scene.BIMModelProperties.ifc_class" to "IfcWallType" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And I set "scene.BIMModelProperties.ifc_class" to "IfcWindowType" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And I prepare to undo And the object "IfcWall/Wall" is selected And I set "scene.BIMModelProperties.ifc_class" to "IfcWindowType" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And I undo Then nothing happens @@ -478,9 +442,9 @@ Scenario: Undo test - create a wall with window opening, flip it and undo Given an empty IFC project And I load the demo construction library And I set "scene.BIMModelProperties.ifc_class" to "IfcWallType" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And I set "scene.BIMModelProperties.ifc_class" to "IfcWindowType" - And I press "bim.hotkey(hotkey='S_A')" + And I press "bim.add_occurrence" And the object "IfcWall/Wall" is selected And I prepare to undo And I press "bim.hotkey(hotkey='S_F')" @@ -489,22 +453,24 @@ Scenario: Undo test - create a wall with window opening, flip it and undo Scenario: Create window type based on window modifier, add an occurrence of it and edit it Given an empty IFC project - And I set "scene.BIMModelProperties.type_class" to "IfcWindowType" - And I set "scene.BIMModelProperties.type_predefined_type" to "WINDOW" - And I set "scene.BIMModelProperties.type_template" to "WINDOW" - And I press "bim.add_type()" - And I press "bim.hotkey(hotkey='S_A')" + And I trigger "Add Element" + And I set the "Class" property to "IfcWindowType" + And I set the "Predefined Type" property to "WINDOW" + And I set the "Representation" property to "Window" + When I click "OK" + And I press "bim.add_occurrence" And I press "bim.enable_editing_window()" And I press "bim.finish_editing_window()" Then nothing happens Scenario: Create door type based on door modifier, add an occurrence of it and edit it Given an empty IFC project - And I set "scene.BIMModelProperties.type_class" to "IfcDoorType" - And I set "scene.BIMModelProperties.type_predefined_type" to "DOOR" - And I set "scene.BIMModelProperties.type_template" to "DOOR" - And I press "bim.add_type()" - And I press "bim.hotkey(hotkey='S_A')" + And I trigger "Add Element" + And I set the "Class" property to "IfcDoorType" + And I set the "Predefined Type" property to "DOOR" + And I set the "Representation" property to "Door" + When I click "OK" + And I press "bim.add_occurrence" And I press "bim.enable_editing_door()" And I press "bim.finish_editing_door()" Then nothing happens diff --git a/src/bonsai/test/bim/test_feature.py b/src/bonsai/test/bim/test_feature.py index e6932cb1b5..cdb080e65c 100644 --- a/src/bonsai/test/bim/test_feature.py +++ b/src/bonsai/test/bim/test_feature.py @@ -1228,7 +1228,7 @@ def the_object_name_dimensions_are_dimensions(name, dimensions): actual_dimensions = list(the_object_name_exists(name).dimensions) expected_dimensions = [float(co) for co in dimensions.split(",")] for i, number in enumerate(actual_dimensions): - assert is_x(number, expected_dimensions[i]), f"Expected {expected_dimensions[i]} but got {number}" + assert is_x(number, expected_dimensions[i]), f"Expected {expected_dimensions} but got {actual_dimensions}" @then(parsers.parse('the object "{name}" top right corner is at "{location}"')) @@ -1237,7 +1237,7 @@ def the_object_name_top_right_corner_is_at_location(name, location): obj_corner = obj.matrix_world @ Vector(obj.bound_box[6]) assert ( obj_corner - Vector([float(co) for co in location.split(",")]) - ).length < 0.1, f"Object has top right corner {obj_corner}" + ).length < 0.1, f"Object has top right corner {obj_corner} instead of {location}" @then(parsers.parse('the object "{name}" bottom left corner is at "{location}"')) @@ -1246,7 +1246,7 @@ def the_object_name_bottom_left_corner_is_at_location(name, location): obj_corner = obj.matrix_world @ Vector(obj.bound_box[0]) assert ( obj_corner - Vector([float(co) for co in location.split(",")]) - ).length < 0.1, f"Object has bottom left corner {obj_corner}" + ).length < 0.1, f"Object has bottom left corner {obj_corner} instead of {location}" @then(parsers.parse('the object "{name}" is contained in "{container_name}"')) @@ -1305,7 +1305,7 @@ def the_object_name_has_no_modifiers(name): @given(parsers.parse('I load the IFC test file "{filepath}"')) def i_load_the_ifc_test_file(filepath): filepath = f"{variables['cwd']}{filepath}" - bpy.ops.bim.load_project(filepath=filepath, use_relative_path=True) + bpy.ops.bim.load_project(filepath=filepath) @given("I load the demo construction library") @@ -1370,10 +1370,11 @@ def prepare_undo(): @when(parsers.parse("I undo")) @then(parsers.parse("I undo")) def hit_undo(): - # bpy.ops.ed.undo_push(message="UNDO STEP") - override = tool.Blender.get_viewport_context() - with bpy.context.temp_override(**override): - bpy.ops.ed.undo() + bpy.ops.ed.undo_push(message="UNDO STEP") + bpy.ops.ed.undo() + # override = tool.Blender.get_viewport_context() + # with bpy.context.temp_override(**override): + # bpy.ops.ed.undo() @then(parsers.parse('the object "{obj_name1}" has a connection with "{obj_name2}"')) @@ -1431,9 +1432,6 @@ def the_obj_layer_lenght_is_set_to(value): eval("bpy.context.scene.BIMModelProperties.length") except: assert False, f"Property BIMModelProperties.length does not exist when trying to set to value {value}" - - print(50 * "@", bpy.context.selected_objects) - props = tool.Model.get_model_props() props.length = value bpy.ops.bim.change_layer_length(length=value)