Fix dxf arc export for some partial circles (#455)
* Fix dxf arc export for some partial circles * Fix dxf export formatting, add test * Black related update Co-authored-by: Scott Nagy <i@sna.gy> Co-authored-by: Adam Urbańczyk <adam-urbanczyk@users.noreply.github.com>
This commit is contained in:
@ -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)
|
||||
@ -101,10 +101,10 @@ DXF_CONVERTERS = {
|
||||
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
|
||||
|
||||
@ -14,9 +14,9 @@ from tests import BaseTest
|
||||
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)
|
||||
|
||||
@ -116,6 +116,17 @@ class TestExporters(BaseTest):
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user