Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dxf arc export for some partial circles #455

Merged
merged 3 commits into from
Sep 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cadquery/occ_impl/exporters/dxf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def _dxf_circle(e: Edge, msp: ezdxf.layouts.Modelspace, plane: Plane):
a1 = RAD2DEG * (geom.FirstParameter() - phi)
a2 = RAD2DEG * (geom.LastParameter() - phi)
else:
a1 = -RAD2DEG * (geom.LastParameter() + phi)
a2 = -RAD2DEG * (geom.FirstParameter() + phi)
a1 = -RAD2DEG * (geom.LastParameter() - phi) + 180
a2 = -RAD2DEG * (geom.FirstParameter() - phi) + 180

if e.IsClosed():
msp.add_circle((c.X(), c.Y(), c.Z()), r)
Expand Down Expand Up @@ -101,10 +101,10 @@ def _dxf_spline(e: Edge, msp: ezdxf.layouts.Modelspace, plane: Plane):
def exportDXF(w: Workplane, fname: str):
"""
Export Workplane content to DXF. Works with 2D sections.

:param w: Workplane to be exported.
:param fname: output filename.

"""

plane = w.plane
Expand Down
17 changes: 14 additions & 3 deletions tests/test_exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
class TestExporters(BaseTest):
def _exportBox(self, eType, stringsToFind, tolerance=0.1, angularTolerance=0.1):
"""
Exports a test object, and then looks for
all of the supplied strings to be in the result
returns the result in case the case wants to do more checks also
Exports a test object, and then looks for
all of the supplied strings to be in the result
returns the result in case the case wants to do more checks also
"""
p = Workplane("XY").box(1, 2, 3)

Expand Down Expand Up @@ -116,6 +116,17 @@ def testDXF(self):
self.assertAlmostEqual(s3.val().Area(), s3_i.val().Area(), 6)
self.assertAlmostEqual(s3.edges().size(), s3_i.edges().size())

cyl = Workplane("XY").circle(22).extrude(10, both=True).translate((-50, 0, 0))

s4 = Workplane("XY").box(80, 60, 5).cut(cyl).section()

exporters.dxf.exportDXF(s4, "res4.dxf")

s4_i = importers.importDXF("res4.dxf")

self.assertAlmostEqual(s4.val().Area(), s4_i.val().Area(), 6)
self.assertAlmostEqual(s4.edges().size(), s4_i.edges().size())

def testTypeHandling(self):

with self.assertRaises(ValueError):
Expand Down