Change default polyline and spline behavior
This commit is contained in:
@ -1345,7 +1345,7 @@ class Workplane(CQ):
|
||||
return self.newObject([self.plane.toWorldCoords(newCenter)])
|
||||
|
||||
def spline(self, listOfXYTuple, tangents=None, periodic=False,
|
||||
forConstruction=False, includeCurrent=True, makeWire=False):
|
||||
forConstruction=False, includeCurrent=False, makeWire=False):
|
||||
"""
|
||||
Create a spline interpolated through the provided points.
|
||||
|
||||
@ -1895,7 +1895,8 @@ class Workplane(CQ):
|
||||
|
||||
return self.eachpoint(_makePolygon, True)
|
||||
|
||||
def polyline(self, listOfXYTuple, forConstruction=False):
|
||||
def polyline(self, listOfXYTuple, forConstruction=False,
|
||||
includeCurrent=False):
|
||||
"""
|
||||
Create a polyline from a list of points
|
||||
|
||||
@ -1904,6 +1905,7 @@ class Workplane(CQ):
|
||||
:param forConstruction: whether or not the edges are used for reference
|
||||
:type forConstruction: true if the edges are for reference, false if they are for creating geometry
|
||||
part geometry
|
||||
:param includeCurrent: use current point as a starting point of the polyline
|
||||
:return: a new CQ object with a list of edges on the stack
|
||||
|
||||
*NOTE* most commonly, the resulting wire should be closed.
|
||||
@ -1912,11 +1914,13 @@ class Workplane(CQ):
|
||||
# Our list of new edges that will go into a new CQ object
|
||||
edges = []
|
||||
|
||||
# The very first startPoint comes from our original object, but not after that
|
||||
if includeCurrent:
|
||||
startPoint = self._findFromPoint(False)
|
||||
else:
|
||||
startPoint = self.plane.toWorldCoords(listOfXYTuple[0])
|
||||
|
||||
# Draw a line for each set of points, starting from the from-point of the original CQ object
|
||||
for curTuple in listOfXYTuple:
|
||||
for curTuple in listOfXYTuple[1:]:
|
||||
endPoint = self.plane.toWorldCoords(curTuple)
|
||||
|
||||
edges.append(Edge.makeLine(startPoint, endPoint))
|
||||
|
||||
@ -400,6 +400,7 @@ class TestCadQuery(BaseTest):
|
||||
Tests the operation of sweeping a wire(s) along a path
|
||||
"""
|
||||
pts = [
|
||||
(0, 0),
|
||||
(0, 1),
|
||||
(1, 2),
|
||||
(2, 4)
|
||||
@ -1062,6 +1063,7 @@ class TestCadQuery(BaseTest):
|
||||
t = 1.5
|
||||
|
||||
points = [
|
||||
(0, 0),
|
||||
(0, t / 2),
|
||||
(r / 2 - 1.5 * t, r / 2 - t),
|
||||
(s / 2, r / 2 - t),
|
||||
@ -1087,6 +1089,7 @@ class TestCadQuery(BaseTest):
|
||||
t = 1.5
|
||||
|
||||
points = [
|
||||
(0, 0),
|
||||
(0, t/2),
|
||||
(r/2-1.5*t, r/2-t),
|
||||
(s/2, r/2-t),
|
||||
@ -1122,6 +1125,7 @@ class TestCadQuery(BaseTest):
|
||||
# i just side-stepped it for now
|
||||
|
||||
pts = [
|
||||
(0, 0),
|
||||
(0, H / 2.0),
|
||||
(W / 2.0, H / 2.0),
|
||||
(W / 2.0, (H / 2.0 - t)),
|
||||
@ -1907,7 +1911,7 @@ class TestCadQuery(BaseTest):
|
||||
"""
|
||||
decimal_places = 9
|
||||
|
||||
pts = [(90,0),(90,30),(30,30),(30,60),(0.0,60)]
|
||||
pts = [(0,0),(90,0),(90,30),(30,30),(30,60),(0.0,60)]
|
||||
|
||||
r = Workplane("XY").polyline(pts).close().extrude(10.0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user