Skip to content

Commit

Permalink
Merge pull request #516 from jdegenstein/polylines
Browse files Browse the repository at this point in the history
change Polyline and FilletPolyline to accept 2 pts as minimum
  • Loading branch information
jdegenstein authored Jan 31, 2024
2 parents 8cd3567 + 0676565 commit d52b600
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/build123d/objects_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,13 @@ class FilletPolyline(BaseLineObject):
are filleted to a given radius.
Args:
pts (Union[VectorLike, Iterable[VectorLike]]): sequence of three or more points
pts (Union[VectorLike, Iterable[VectorLike]]): sequence of two or more points
radius (float): radius of filleted corners
close (bool, optional): close by generating an extra Edge. Defaults to False.
mode (Mode, optional): combination mode. Defaults to Mode.ADD.
Raises:
ValueError: Three or more points not provided
ValueError: Two or more points not provided
ValueError: radius must be positive
"""

Expand All @@ -378,8 +378,8 @@ def __init__(

pts = flatten_sequence(*pts)

if len(pts) < 3:
raise ValueError("filletpolyline requires three or more pts")
if len(pts) < 2:
raise ValueError("FilletPolyline requires two or more pts")
if radius <= 0:
raise ValueError("radius must be positive")

Expand Down Expand Up @@ -643,12 +643,12 @@ class Polyline(BaseLineObject):
Add a sequence of straight lines defined by successive point pairs.
Args:
pts (Union[VectorLike, Iterable[VectorLike]]): sequence of three or more points
pts (Union[VectorLike, Iterable[VectorLike]]): sequence of two or more points
close (bool, optional): close by generating an extra Edge. Defaults to False.
mode (Mode, optional): combination mode. Defaults to Mode.ADD.
Raises:
ValueError: Three or more points not provided
ValueError: Two or more points not provided
"""

_applies_to = [BuildLine._tag]
Expand All @@ -663,8 +663,8 @@ def __init__(
validate_inputs(context, self)

pts = flatten_sequence(*pts)
if len(pts) < 3:
raise ValueError("polyline requires three or more pts")
if len(pts) < 2:
raise ValueError("Polyline requires two or more pts")

lines_pts = WorkplaneList.localize(*pts)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_build_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def test_filletpolyline(self):
self.assertEqual(len(p.edges().filter_by(GeomType.LINE)), 4)

with self.assertRaises(ValueError):
FilletPolyline((0, 0), (1, 0), radius=0.1)
FilletPolyline((0, 0), radius=0.1)
with self.assertRaises(ValueError):
FilletPolyline((0, 0), (1, 0), (1, 1), radius=-1)

Expand Down Expand Up @@ -308,7 +308,7 @@ def test_error_conditions(self):
Line((0, 0)) # Need two points
with self.assertRaises(ValueError):
with BuildLine():
Polyline((0, 0), (1, 1)) # Need three points
Polyline((0, 0)) # Need two points
with self.assertRaises(ValueError):
with BuildLine():
RadiusArc((0, 0), (1, 0), 0.1) # Radius too small
Expand Down

0 comments on commit d52b600

Please sign in to comment.