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

Method close

cadquery/cq.py:2735–2767  ·  view source on GitHub ↗

End construction, and attempt to build a closed wire. :return: a CQ object with a completed wire on the stack, if possible. After 2D (or 3D) drafting with methods such as lineTo, threePointArc, tangentArcPoint and polyline, it is necessary to convert the edges

(self: T)

Source from the content-addressed store, hash-verified

2733 return self.newObject(edges)
2734
2735 def close(self: T) -> T:
2736 """
2737 End construction, and attempt to build a closed wire.
2738
2739 :return: a CQ object with a completed wire on the stack, if possible.
2740
2741 After 2D (or 3D) drafting with methods such as lineTo, threePointArc,
2742 tangentArcPoint and polyline, it is necessary to convert the edges
2743 produced by these into one or more wires.
2744
2745 When a set of edges is closed, CadQuery assumes it is safe to build
2746 the group of edges into a wire. This example builds a simple triangular
2747 prism::
2748
2749 s = Workplane().lineTo(1, 0).lineTo(1, 1).close().extrude(0.2)
2750 """
2751 endPoint = self._findFromPoint(True)
2752
2753 if self.ctx.firstPoint is None:
2754 raise ValueError("No start point specified - cannot close")
2755 else:
2756 startPoint = self.ctx.firstPoint
2757
2758 # Check if there is a distance between startPoint and endPoint
2759 # that is larger than what is considered a numerical error.
2760 # If so; add a line segment between endPoint and startPoint
2761 if endPoint.sub(startPoint).Length > 1e-6:
2762 self.polyline([endPoint, startPoint])
2763
2764 # Need to reset the first point after closing a wire
2765 self.ctx.firstPoint = None
2766
2767 return self.wire()
2768
2769 def largestDimension(self) -> float:
2770 """

Callers 15

test_mirror_faceMethod · 0.45
test_bezier_curveMethod · 0.45
readFileAsStringFunction · 0.45
writeStringToFileFunction · 0.45
test_deleteFunction · 0.45
test_edge_interfaceFunction · 0.45
test_bezierFunction · 0.45
test_assembleFunction · 0.45
test_locatedFunction · 0.45
test_constraint_solverFunction · 0.45
test_mixed_closeFunction · 0.45
test_splineMethod · 0.45

Calls 4

_findFromPointMethod · 0.95
polylineMethod · 0.95
wireMethod · 0.95
subMethod · 0.80

Tested by 15

test_mirror_faceMethod · 0.36
test_bezier_curveMethod · 0.36
test_deleteFunction · 0.36
test_edge_interfaceFunction · 0.36
test_bezierFunction · 0.36
test_assembleFunction · 0.36
test_locatedFunction · 0.36
test_constraint_solverFunction · 0.36
test_mixed_closeFunction · 0.36
test_splineMethod · 0.36
testDXFMethod · 0.36
test_dxf_approxFunction · 0.36