updated to handle polygons without closed lines

This commit is contained in:
x0pherl 2025-10-31 23:18:54 -04:00
parent 8bf4e17d94
commit 9f62ed4ca4
2 changed files with 16 additions and 5 deletions

View file

@ -824,12 +824,13 @@ class FilletPolyline(BaseLineObject):
radius_list = [radius] * len(points) # Single radius for all points
else:
radius_list = list(radius)
if len(radius_list) != len(points):
if len(radius_list) != len(points) - int(not close) * 2:
raise ValueError(
f"radius list length ({len(radius_list)}) must match points ({len(points)})"
f"radius list length ({len(radius_list)}) must match angle count ({ len(points) - int(not close) * 2})"
)
if any(r <= 0 for r in radius_list):
raise ValueError("radius must be positive")
for r in radius_list:
if r <= 0:
raise ValueError(f"radius {r} must be positive")
lines_pts = WorkplaneList.localize(*points)
@ -867,7 +868,7 @@ class FilletPolyline(BaseLineObject):
other_vertices = {ve for e in edges for ve in e.vertices() if ve != vertex}
third_edge = Edge.make_line(*[v for v in other_vertices])
fillet_face = Face(Wire(edges + [third_edge])).fillet_2d(
radius_list[i], [vertex]
radius_list[i - int(not close)], [vertex]
)
fillets.append(fillet_face.edges().filter_by(GeomType.CIRCLE)[0])

View file

@ -193,6 +193,16 @@ class BuildLineTests(unittest.TestCase):
close=True,
)
with self.assertRaises(ValueError):
p = FilletPolyline(
(0, 0),
(10, 0),
(10, 10),
(0, 10),
radius=(1, 2, 3, 4),
close=False,
)
with self.assertRaises(ValueError):
p = FilletPolyline(
(0, 0),