From c4b3e57677f70a569c465d336375ce7b94cdea52 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sun, 30 Jun 2024 21:40:21 +1000 Subject: [PATCH] Fix bug where using the alignment tool broke on flipped non-LAYER2 objects The alignment tool was initially designed specifically for LAYER2 objects. It doesn't have to be, so now LAYER2 is a special case where it may have its baselines and sidelines aligned whereas non-LAYER2 objects simply align based on bbox. --- .../blenderbim/bim/module/model/wall.py | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/model/wall.py b/src/blenderbim/blenderbim/bim/module/model/wall.py index 5dd6be2070..a9fec06311 100644 --- a/src/blenderbim/blenderbim/bim/module/model/wall.py +++ b/src/blenderbim/blenderbim/bim/module/model/wall.py @@ -367,17 +367,22 @@ class DumbWallAligner: self.align_rotation() if self.is_rotation_flipped(): - DumbWallJoiner().flip(self.wall) - bpy.context.view_layer.update() + element = tool.Ifc.get_entity(self.wall) + if tool.Model.get_usage_type(element) == "LAYER2": + DumbWallJoiner().flip(self.wall) + bpy.context.view_layer.update() + snap_point = self.wall.matrix_world @ Vector(self.wall.bound_box[3]) + else: + snap_point = self.wall.matrix_world @ Vector(self.wall.bound_box[0]) + else: + snap_point = self.wall.matrix_world @ Vector(self.wall.bound_box[3]) start = self.reference_wall.matrix_world @ Vector(self.reference_wall.bound_box[3]) end = self.reference_wall.matrix_world @ Vector(self.reference_wall.bound_box[7]) - snap_point = self.wall.matrix_world @ Vector(self.wall.bound_box[3]) - offset = snap_point - self.wall.matrix_world.translation - point, _ = mathutils.geometry.intersect_point_line(snap_point, start, end) + offset = snap_point - self.wall.matrix_world.translation new_origin = point - offset self.wall.matrix_world.translation[0], self.wall.matrix_world.translation[1] = new_origin.xy @@ -385,17 +390,22 @@ class DumbWallAligner: self.align_rotation() if self.is_rotation_flipped(): - DumbWallJoiner().flip(self.wall) - bpy.context.view_layer.update() + element = tool.Ifc.get_entity(self.wall) + if tool.Model.get_usage_type(element) == "LAYER2": + DumbWallJoiner().flip(self.wall) + bpy.context.view_layer.update() + snap_point = self.wall.matrix_world @ Vector(self.wall.bound_box[0]) + else: + snap_point = self.wall.matrix_world @ Vector(self.wall.bound_box[3]) + else: + snap_point = self.wall.matrix_world @ Vector(self.wall.bound_box[0]) start = self.reference_wall.matrix_world @ Vector(self.reference_wall.bound_box[0]) end = self.reference_wall.matrix_world @ Vector(self.reference_wall.bound_box[4]) - snap_point = self.wall.matrix_world @ Vector(self.wall.bound_box[0]) - offset = snap_point - self.wall.matrix_world.translation - point, _ = mathutils.geometry.intersect_point_line(snap_point, start, end) + offset = snap_point - self.wall.matrix_world.translation new_origin = point - offset self.wall.matrix_world.translation[0], self.wall.matrix_world.translation[1] = new_origin.xy @@ -842,7 +852,7 @@ class DumbWallJoiner: blenderbim.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=wall1) element1 = tool.Ifc.get_entity(wall1) - if not element1: + if not element1 or tool.Model.get_usage_type(element1) != "LAYER2": return for rel in element1.ConnectedTo: