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 <noreply@anthropic.com>
This commit is contained in:
Dion Moult
2026-03-14 20:33:05 +11:00
parent 473d689cf2
commit ea64f1b6b9
+5 -2
View File
@@ -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: