@@ -1756,10 +1756,9 @@ def spline(
1756
1756
makeWire : bool = False ,
1757
1757
) -> T :
1758
1758
"""
1759
- Create a spline interpolated through the provided points.
1759
+ Create a spline interpolated through the provided points (2D or 3D) .
1760
1760
1761
1761
:param listOfXYTuple: points to interpolate through
1762
- :type listOfXYTuple: list of 2-tuple
1763
1762
:param tangents: vectors specifying the direction of the tangent to the
1764
1763
curve at each of the specified interpolation points.
1765
1764
@@ -1852,6 +1851,52 @@ def spline(
1852
1851
1853
1852
return self .newObject ([rv_w if makeWire else e ])
1854
1853
1854
+ def splineApprox (
1855
+ self : T ,
1856
+ points : Iterable [VectorLike ],
1857
+ tol : Optional [float ] = 1e-6 ,
1858
+ minDeg : int = 1 ,
1859
+ maxDeg : int = 6 ,
1860
+ smoothing : Optional [Tuple [float , float , float ]] = (1 , 1 , 1 ),
1861
+ forConstruction : bool = False ,
1862
+ includeCurrent : bool = False ,
1863
+ makeWire : bool = False ,
1864
+ ) -> T :
1865
+ """
1866
+ Create a spline interpolated through the provided points (2D or 3D).
1867
+
1868
+ :param points: points to interpolate through
1869
+ :param tol: tolerance of the algorithm (default: 1e-6)
1870
+ :param minDeg: minimum spline degree (default: 1)
1871
+ :param maxDeg: maximum spline degree (default: 6)
1872
+ :param smoothing: optional parameters for the variational smoothing algorithm (default: (1,1,1))
1873
+ :param includeCurrent: use current point as a starting point of the curve
1874
+ :param makeWire: convert the resulting spline edge to a wire
1875
+ :return: a Workplane object with the current point at the end of the spline
1876
+
1877
+ *WARNING* for advanced users.
1878
+ """
1879
+
1880
+ allPoints = self ._toVectors (points , includeCurrent )
1881
+
1882
+ e = Edge .makeSplineApprox (
1883
+ allPoints ,
1884
+ minDeg = minDeg ,
1885
+ maxDeg = maxDeg ,
1886
+ smoothing = smoothing ,
1887
+ ** ({"tol" : tol } if tol else {}),
1888
+ )
1889
+
1890
+ if makeWire :
1891
+ rv_w = Wire .assembleEdges ([e ])
1892
+ if not forConstruction :
1893
+ self ._addPendingWire (rv_w )
1894
+ else :
1895
+ if not forConstruction :
1896
+ self ._addPendingEdge (e )
1897
+
1898
+ return self .newObject ([rv_w if makeWire else e ])
1899
+
1855
1900
def parametricCurve (
1856
1901
self : T ,
1857
1902
func : Callable [[float ], VectorLike ],
0 commit comments