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)
| 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 | """ |