From 679eb215296630803cb253da904a0e3077e798e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20N=C3=A4slund?= Date: Thu, 26 Apr 2018 22:21:06 +0200 Subject: [PATCH] Use local coordinates and not global coordinates in close() When getting the endPoint in close() ; use local coordinates and not global coordinates. It does matter when the origin of the workplane is moved. --- cadquery/cq.py | 2 +- tests/TestCadQuery.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cadquery/cq.py b/cadquery/cq.py index fd614ef..a84a010 100644 --- a/cadquery/cq.py +++ b/cadquery/cq.py @@ -1773,7 +1773,7 @@ def close(self): s = Workplane().lineTo(1,0).lineTo(1,1).close().extrude(0.2) """ - endPoint = self._findFromPoint(False) + endPoint = self._findFromPoint(True) startPoint = self.ctx.firstPoint # Check if there is a distance between startPoint and endPoint diff --git a/tests/TestCadQuery.py b/tests/TestCadQuery.py index 9b5a245..4085db3 100644 --- a/tests/TestCadQuery.py +++ b/tests/TestCadQuery.py @@ -1607,3 +1607,13 @@ def testClose(self): # The b shape shall have twice the volume of the a shape. self.assertAlmostEqual(a.val().wrapped.Volume * 2.0, b.val().wrapped.Volume) + + # Testcase 3 from issue #238 + thickness = 3 + length = 10 + width = 5 + + obj = Workplane('XY', origin=(0, 0, -thickness / 2)) \ + .moveTo(length / 2, 0).threePointArc((0, width / 2), (-length / 2, 0)) \ + .threePointArc((0, -width / 2), (length / 2, 0)) \ + .close().extrude(thickness)