MCPcopy
hub / github.com/CadQuery/cadquery / polyline

Method polyline

cadquery/cq.py:2692–2733  ·  view source on GitHub ↗

Create a polyline from a list of points :param listOfXYTuple: a list of points in Workplane coordinates (2D or 3D) :param forConstruction: whether or not the edges are used for reference :type forConstruction: true if the edges are for reference, false if they are f

(
        self: T,
        listOfXYTuple: Sequence[VectorLike],
        forConstruction: bool = False,
        includeCurrent: bool = False,
    )

Source from the content-addressed store, hash-verified

2690 return self.eachpoint(lambda loc: p.moved(loc), True)
2691
2692 def polyline(
2693 self: T,
2694 listOfXYTuple: Sequence[VectorLike],
2695 forConstruction: bool = False,
2696 includeCurrent: bool = False,
2697 ) -> T:
2698 """
2699 Create a polyline from a list of points
2700
2701 :param listOfXYTuple: a list of points in Workplane coordinates (2D or 3D)
2702 :param forConstruction: whether or not the edges are used for reference
2703 :type forConstruction: true if the edges are for reference, false if they are for creating geometry
2704 part geometry
2705 :param includeCurrent: use current point as a starting point of the polyline
2706 :return: a new CQ object with a list of edges on the stack
2707
2708 *NOTE* most commonly, the resulting wire should be closed.
2709 """
2710
2711 # Our list of new edges that will go into a new CQ object
2712 edges = []
2713
2714 if includeCurrent:
2715 startPoint = self._findFromPoint(False)
2716 points = listOfXYTuple
2717 else:
2718 startPoint = self.plane.toWorldCoords(listOfXYTuple[0])
2719 points = listOfXYTuple[1:]
2720
2721 # Draw a line for each set of points, starting from the from-point of the original CQ object
2722 for curTuple in points:
2723 endPoint = self.plane.toWorldCoords(curTuple)
2724
2725 edges.append(Edge.makeLine(startPoint, endPoint))
2726
2727 # We need to move the start point for the next line that we draw or we get stuck at the same startPoint
2728 startPoint = endPoint
2729
2730 if not forConstruction:
2731 self._addPendingEdge(edges[-1])
2732
2733 return self.newObject(edges)
2734
2735 def close(self: T) -> T:
2736 """

Callers 15

closeMethod · 0.95
testIbeamMethod · 0.95
testSweepMethod · 0.80
testUnorderedMirrorMethod · 0.80
testChainedMirrorMethod · 0.80
testClosedShellMethod · 0.80
test_assembleEdgesMethod · 0.80
test_interpPlateMethod · 0.80
testOffset2DMethod · 0.80
test_close_3D_pointsMethod · 0.80
Ex009_Polylines.pyFile · 0.80

Calls 6

_findFromPointMethod · 0.95
_addPendingEdgeMethod · 0.95
newObjectMethod · 0.95
toWorldCoordsMethod · 0.80
appendMethod · 0.80
makeLineMethod · 0.80

Tested by 10

testIbeamMethod · 0.76
testSweepMethod · 0.64
testUnorderedMirrorMethod · 0.64
testChainedMirrorMethod · 0.64
testClosedShellMethod · 0.64
test_assembleEdgesMethod · 0.64
test_interpPlateMethod · 0.64
testOffset2DMethod · 0.64
test_close_3D_pointsMethod · 0.64