From 1309c2e70b93a635b94874195546ee3a65ff5547 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Jul 2026 23:53:58 +0000 Subject: [PATCH] Fix cross-loop wall joining for composite slab profiles When a slab has two separate closed loops (IfcCompositeProfileDef), the flat walls list was passed to DumbWallJoiner in a circular ring, cross-connecting the last wall of loop 1 to the first wall of loop 2. The joiner then computed an intersection between non-intersecting walls, producing endpoints far outside the slab's bounding box. Group walls by loop in derive_from_slab and join only within each group. Generated with the assistance of an AI coding tool. --- src/bonsai/bonsai/bim/module/model/wall.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/model/wall.py b/src/bonsai/bonsai/bim/module/model/wall.py index 1ad2af0fce..8f1d01c5bb 100644 --- a/src/bonsai/bonsai/bim/module/model/wall.py +++ b/src/bonsai/bonsai/bim/module/model/wall.py @@ -1012,11 +1012,12 @@ class AddWallsFromSlab(bpy.types.Operator, tool.Ifc.Operator): "Please select a slab.", ) return {"FINISHED"} - walls = DumbWallGenerator(self.relating_type).generate("SLAB") + wall_groups = DumbWallGenerator(self.relating_type).generate("SLAB") - if walls: - for wall1, wall2 in zip(walls, walls[1:] + [walls[0]]): - DumbWallJoiner().connect(wall2["obj"], wall1["obj"]) + if wall_groups: + for walls in wall_groups: + for wall1, wall2 in zip(walls, walls[1:] + [walls[0]]): + DumbWallJoiner().connect(wall2["obj"], wall1["obj"]) class DrawPolylineWall(bpy.types.Operator, PolylineOperator, tool.Ifc.Operator): @@ -1403,7 +1404,7 @@ class DumbWallGenerator: profiles = swept_area.Profiles else: profiles = [swept_area] - walls = [] + wall_groups = [] for profile in profiles: outer_curve = profile.OuterCurve if self._curve_has_arc_segments(outer_curve): @@ -1420,12 +1421,15 @@ class DumbWallGenerator: continue if not tool.Cad.is_counter_clockwise_order(polyline_points[0], polyline_points[1], polyline_points[2]): polyline_points = polyline_points[::-1] + loop_walls = [] for i in range(len(polyline_points) - 1): vec1 = polyline_points[i] vec2 = polyline_points[i + 1] coords = (vec1, vec2) - walls.append(self.create_wall_from_2_points(coords)) - return walls + loop_walls.append(self.create_wall_from_2_points(coords)) + if loop_walls: + wall_groups.append(loop_walls) + return wall_groups def create_wall_from_2_points(self, coords, should_round=False) -> Union[dict[str, Any], None]: direction = coords[1] - coords[0]