From ea64f1b6b9427706b2b0dca6138216a23648e6b6 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sat, 14 Mar 2026 20:33:05 +1100 Subject: [PATCH] Fix #7770, #7747, #7572, #7522, #7416, #7086: Bug when first point in poly tool clicked twice Previous logic always skipped the first point. Instead, it should only skip when actually closing a loop (i.e. >= 3 points). Co-Authored-By: Claude Opus 4.6 --- src/bonsai/bonsai/tool/polyline.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bonsai/bonsai/tool/polyline.py b/src/bonsai/bonsai/tool/polyline.py index 5a91fc79b8..542bc23005 100644 --- a/src/bonsai/bonsai/tool/polyline.py +++ b/src/bonsai/bonsai/tool/polyline.py @@ -533,9 +533,12 @@ class Polyline(bonsai.core.tool.Polyline): polyline_data = polyline_data[0] polyline_points = polyline_data.polyline_points if polyline_points: - # Avoids creating two points at the same location - for point in polyline_points[1:]: # The first can be repeated to form a wall loop + # Avoids creating two points at the same location. + # The only exception is repeating the first point to close a loop (requires >= 3 existing points). + for i, point in enumerate(polyline_points): if (x, y, z) == (point.x, point.y, point.z): + if i == 0 and len(polyline_points) >= 3: + continue return "Cannot create two points at the same location" # Avoids creating overlapping edges if len(polyline_points) > 1: