From ac4e2f142b54af7f226834950b69cefa439f4aa6 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 5 Oct 2022 15:26:27 +1100 Subject: [PATCH] Openings now move with the host, but also intuitively stay along the local X axis of the host --- .../blenderbim/bim/module/model/wall.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/blenderbim/blenderbim/bim/module/model/wall.py b/src/blenderbim/blenderbim/bim/module/model/wall.py index 23a8abe119..afc1542b9f 100644 --- a/src/blenderbim/blenderbim/bim/module/model/wall.py +++ b/src/blenderbim/blenderbim/bim/module/model/wall.py @@ -1012,9 +1012,26 @@ class DumbWallJoiner: "geometry.assign_representation", tool.Ifc.get(), product=element, representation=new_body ) + previous_matrix = obj.matrix_world.copy() + previous_origin = obj.location.copy() obj.location[0], obj.location[1] = self.body[0] bpy.context.view_layer.update() if tool.Ifc.is_moved(obj): + # Openings should move with the host overall ... + # ... except their position should stay the same along the local X axis of the wall + for opening in [r.RelatedOpeningElement for r in element.HasOpenings]: + percent = tool.Cad.edge_percent( + self.body[0], (previous_origin.to_2d(), (previous_matrix @ Vector((1, 0, 0))).to_2d()) + ) + is_x_offset_increased = True if percent < 0 else False + + change_in_x = (self.body[0] - previous_origin.to_2d()).length + coordinates = list(opening.ObjectPlacement.RelativePlacement.Location.Coordinates) + if is_x_offset_increased: + coordinates[0] += change_in_x + else: + coordinates[0] -= change_in_x + opening.ObjectPlacement.RelativePlacement.Location.Coordinates = coordinates blenderbim.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=obj) blenderbim.core.geometry.switch_representation( tool.Geometry,