From 294eba24c46c04320fb8620bfbde85b5d36130c9 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sun, 23 May 2021 09:32:39 +1000 Subject: [PATCH] You can now unjoin walls --- .../blenderbim/bim/module/model/operator.py | 21 ++++++++++++++++++- .../blenderbim/bim/module/model/ui.py | 2 ++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/blenderbim/blenderbim/bim/module/model/operator.py b/src/blenderbim/blenderbim/bim/module/model/operator.py index 07d1aa320a..389b50f195 100644 --- a/src/blenderbim/blenderbim/bim/module/model/operator.py +++ b/src/blenderbim/blenderbim/bim/module/model/operator.py @@ -63,7 +63,13 @@ class JoinWall(bpy.types.Operator): def execute(self, context): selected_objs = context.selected_objects - if len(selected_objs) != 2: + if len(selected_objs) == 0: + return {"FINISHED"} + if not self.join_type: + for obj in selected_objs: + DumbWallJoiner(obj, obj).unjoin() + return {"FINISHED"} + if len(selected_objs) < 2: return {"FINISHED"} joiner = DumbWallJoiner([o for o in selected_objs if o != context.active_object][0], context.active_object) if self.join_type == "T": @@ -99,6 +105,19 @@ class DumbWallJoiner: self.pos_x = self.wall1_matrix.to_quaternion() @ Vector((1, 0, 0)) self.neg_x = self.wall1_matrix.to_quaternion() @ Vector((-1, 0, 0)) + # Unjoining a wall geometrically means to flatten the ends of the wall to + # remove any mitred angle from it. + def unjoin(self): + wall1_min_faces, wall1_max_faces = self.get_wall_end_faces(self.wall1) + min_x = min([v[0] for v in self.wall1.bound_box]) + max_x = max([v[0] for v in self.wall1.bound_box]) + for face in wall1_min_faces: + for v in face.vertices: + self.wall1.data.vertices[v].co[0] = min_x + for face in wall1_max_faces: + for v in face.vertices: + self.wall1.data.vertices[v].co[0] = max_x + # A T-junction is an ordered operation where a single end of wall1 is joined # to wall2 if possible (i.e. walls aren't parallel). Wall2 is not modified. # First, wall1 end faces are identified. We attempt to project an end face diff --git a/src/blenderbim/blenderbim/bim/module/model/ui.py b/src/blenderbim/blenderbim/bim/module/model/ui.py index be78d733f3..984f449e0c 100644 --- a/src/blenderbim/blenderbim/bim/module/model/ui.py +++ b/src/blenderbim/blenderbim/bim/module/model/ui.py @@ -31,6 +31,8 @@ class BIM_PT_authoring_architectural(Panel): row.operator("bim.join_wall").join_type = "T" row.operator("bim.join_wall").join_type = "L" row.operator("bim.join_wall").join_type = "V" + row.operator("bim.join_wall").join_type = "V" + row.operator("bim.join_wall").join_type = "" class BIM_PT_misc_utilities(Panel):