Skip to content

Commit 594d81f

Browse files
committed
Resolves SolidCode#201. extrude_along_path() extrusions where first & last rail points were the same had some ugly joins whether or not connect_ends was set. If first and last points are identical (within sqrt(EPSILON) of each other), assume we want to connect ends, and remove the duplicate rail point.
1 parent 0a4f539 commit 594d81f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

solid/extrude_along_path.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#! /usr/bin/env python
22
from math import radians
33
from solid import OpenSCADObject, Points, Indexes, ScadSize, polyhedron
4-
from solid.utils import euclidify, euc_to_arr, transform_to_point, centroid
4+
from solid.utils import euclidify, euc_to_arr, transform_to_point, centroid, EPSILON
55
from euclid3 import Point2, Point3, Vector2, Vector3
66

77
from typing import Dict, Optional, Sequence, Tuple, Union, List, Callable
@@ -64,6 +64,13 @@ def transform_func(p:Point3, path_norm:float, loop_norm:float): Point3
6464
shape_pt_count = len(shape_pts)
6565

6666
tangent_path_points: List[Point3] = []
67+
68+
# If first & last points are the same, let's close the shape
69+
first_last_equal = ((path_pts[0] - path_pts[-1]).magnitude_squared() < EPSILON)
70+
if first_last_equal:
71+
connect_ends = True
72+
path_pts = path_pts[:][:-1]
73+
6774
if connect_ends:
6875
tangent_path_points = [path_pts[-1]] + path_pts + [path_pts[0]]
6976
else:

0 commit comments

Comments
 (0)