minor refactoring

This commit is contained in:
Hiroshi Murayama 2019-09-28 20:42:11 +09:00
parent a3c750fc06
commit 48b35377b1
7 changed files with 14 additions and 12 deletions

View file

@ -120,7 +120,7 @@ class DxfArcStatement(DxfStatement):
self.start = (self.center[0] + self.radius, self.center[1])
self.end = self.start
self.start_angle = 0
self.end_angle = -360
self.end_angle = 360
self.is_closed = True
elif entity.dxftype == 'ARC':
self.start_angle = self.entity.start_angle

View file

@ -202,20 +202,22 @@ class DxfPath(object):
def to_excellon(self, settings=FileSettings(), pitch=0, width=0):
from gerberex.dxf import DxfArcStatement
if pitch == 0:
x, y = self.statements[0].start
x0, y0 = self.statements[0].start
excellon = 'G00{0}\nM15\n'.format(
CoordinateStmtEx(x=x, y=y).to_excellon(settings))
CoordinateStmtEx(x=x0, y=y0).to_excellon(settings))
for statement in self.statements:
x, y = statement.end
x0, y0 = statement.start
x1, y1 = statement.end
if isinstance(statement, DxfArcStatement):
r = statement.radius
i = statement.center[0] - x0
j = statement.center[1] - y0
excellon += '{0}{1}\n'.format(
'G03' if statement.end_angle > statement.start_angle else 'G02',
CoordinateStmtEx(x=x, y=y, radius=r).to_excellon(settings))
CoordinateStmtEx(x=x1, y=y1, i=i, j=j).to_excellon(settings))
else:
excellon += 'G01{0}\n'.format(
CoordinateStmtEx(x=x, y=y).to_excellon(settings))
CoordinateStmtEx(x=x1, y=y1).to_excellon(settings))
excellon += 'M16\nG05\n'
else:

View file

@ -36,6 +36,6 @@ X119171Y125107D01*
G01*
X119171Y100000D02*
G75*
G02*
G03*
X119171Y100000I-3000J0D01*
M02*

View file

@ -36,6 +36,6 @@ X23162Y45543D01*
G01*
X31749Y21950D02*
G75*
G02*
G03*
X31749Y21950I-2819J-1026D01*
M02*

View file

@ -37,7 +37,7 @@ X9171Y75107D01*
G01*
X9171Y50000D02*
G75*
G02*
G03*
X9171Y50000I-3000J0D01*
G37*
M02*

View file

@ -36,6 +36,6 @@ X9171Y75107D01*
G01*
X9171Y50000D02*
G75*
G02*
G03*
X9171Y50000I-3000J0D01*
M02*

View file

@ -36,6 +36,6 @@ X3610Y29570D01*
G01*
X3610Y19685D02*
G75*
G02*
G03*
X3610Y19685I-1181J0D01*
M02*