aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gerberex/excellon.py48
-rw-r--r--tests/data/ref_drill_inch.txt66
-rw-r--r--tests/data/ref_drill_metric.txt68
-rw-r--r--tests/expects/excellon_offset.txt66
-rw-r--r--tests/expects/excellon_rotate.txt66
-rw-r--r--tests/expects/excellon_save.txt66
-rw-r--r--tests/expects/excellon_to_inch.txt66
-rw-r--r--tests/expects/excellon_to_metric.txt66
8 files changed, 250 insertions, 262 deletions
diff --git a/gerberex/excellon.py b/gerberex/excellon.py
index 657f02a..04d10e9 100644
--- a/gerberex/excellon.py
+++ b/gerberex/excellon.py
@@ -124,13 +124,19 @@ class ExcellonFileEx(ExcellonFile):
def to_inch(self):
if self.units == 'metric':
- super(ExcellonFileEx, self).to_inch()
+ for stmt in self.statements:
+ stmt.to_inch()
+ for tool in self.tools:
+ self.tools[tool].to_inch()
for hit in self.hits:
hit.to_inch()
def to_metric(self):
if self.units == 'inch':
- super(ExcellonFileEx, self).to_metric()
+ for stmt in self.statements:
+ stmt.to_metric()
+ for tool in self.tools:
+ self.tools[tool].to_metric()
for hit in self.hits:
hit.to_metric()
@@ -153,13 +159,27 @@ class ExcellonFileEx(ExcellonFile):
f.write(EndOfProgramStmt().to_excellon() + '\n')
class DrillHitEx(DrillHit):
- def rotate(self, angle, center=(0,0)):
+ def to_inch(self):
+ self.position = tuple(map(inch, self.position))
+
+ def to_metric(self):
+ self.position = tuple(map(metric, self.position))
+
+ def rotate(self, angle, center=(0, 0)):
self.position = rotate(*self.position, angle, center)
def to_excellon(self, settings):
return CoordinateStmtEx(*self.position).to_excellon(settings)
class DrillSlotEx(DrillSlot):
+ def to_inch(self):
+ self.start = tuple(map(inch, self.start))
+ self.end = tuple(map(inch, self.end))
+
+ def to_metric(self):
+ self.start = tuple(map(metric, self.start))
+ self.end = tuple(map(metric, self.end))
+
def rotate(self, angle, center=(0,0)):
self.start = rotate(*self.start, angle, center)
self.end = rotate(*self.end, angle, center)
@@ -190,24 +210,20 @@ class DrillRout(object):
for node in self.nodes[1:]:
excellon += CoordinateStmtEx(*node.position, node.radius,
node.mode).to_excellon(settings) + '\n'
- excellon += 'M16\nG05\n'
+ excellon += 'M16\nG05'
return excellon
def to_inch(self):
- if self.tool.settings.units == 'metric':
- self.tool.to_inch()
- for node in self.nodes:
- node.position = tuple(map(inch, node.position))
- node.radius = inch(
- node.radius) if node.radius is not None else None
+ for node in self.nodes:
+ node.position = tuple(map(inch, node.position))
+ node.radius = inch(
+ node.radius) if node.radius is not None else None
def to_metric(self):
- if self.tool.settings.units == 'inch':
- self.tool.to_metric()
- for node in self.nodes:
- node.position = tuple(map(metric, node.position))
- node.radius = metric(
- node.radius) if node.radius is not None else None
+ for node in self.nodes:
+ node.position = tuple(map(metric, node.position))
+ node.radius = metric(
+ node.radius) if node.radius is not None else None
def offset(self, x_offset=0, y_offset=0):
for node in self.nodes:
diff --git a/tests/data/ref_drill_inch.txt b/tests/data/ref_drill_inch.txt
index 8d31df0..6aea2e0 100644
--- a/tests/data/ref_drill_inch.txt
+++ b/tests/data/ref_drill_inch.txt
@@ -2,42 +2,38 @@ M48
FMAT,2
ICI,OFF
INCH,TZ,00.0000
-M72
-T01C0.0039
-T02C0.0078
+T01C0.0236
+T02C0.0275
+T03C0.0314
+T04C0.0393
%
+G90
+M72
T01
-X1969Y3740
-X2047Y3740
-X2126Y3740
-X2205Y3740
-X2283Y3740
-X2362Y3740
-X2441Y3740
-X2520Y3740
-X2598Y3740
-X2677Y3740
-X2756Y3740
-X2835Y3740
-X2913Y3740
-X2992Y3740
-X3071Y3740
-X3150Y3740
-X3228Y3740
-X3307Y3740
-X3386Y3740
-X3465Y3740
-X3543Y3740
+X1815Y960
+X1815Y1344
+X1421Y2402G85X827Y2402
T02
-X1969Y197
-X2126Y197
-X2283Y197
-X2441Y197
-X2598Y197
-X2756Y197
-X2913Y197
-X3071Y197
-X3228Y197
-X3386Y197
-X3543Y197
+X1421Y1535
+X1421Y768
+X843Y768
+X807Y1535
+T03
+G00X1421Y1152
+M15
+G01X843Y1152
+M16
+G05
+X1417Y2795
+T04
+G00X236Y669
+M15
+G03X630Y276A394
+G01X2598Y276
+G01X2598Y1614
+G03X2205Y2008A394
+G01X236Y2008
+G01X236Y669
+M16
+G05
M30
diff --git a/tests/data/ref_drill_metric.txt b/tests/data/ref_drill_metric.txt
index 87f20f5..903fc48 100644
--- a/tests/data/ref_drill_metric.txt
+++ b/tests/data/ref_drill_metric.txt
@@ -2,44 +2,40 @@ M48
FMAT,2
ICI,OFF
METRIC,TZ,000.000
-M71
-T01C0.100
-T02C0.200
+T01C0.600
+T02C0.700
+T03C0.800
+T04C1.000
%
+G90
+M71
T01
-X5000Y9500
-X5200Y9500
-X5400Y9500
-X5600Y9500
-X5800Y9500
-X6000Y9500
-X6200Y9500
-X6400Y9500
-X6600Y9500
-X6800Y9500
-X7000Y9500
-X7200Y9500
-X7400Y9500
-X7600Y9500
-X7800Y9500
-X8000Y9500
-X8200Y9500
-X8400Y9500
-X8600Y9500
-X8800Y9500
-X9000Y9500
-
+X4610Y2438
+X4610Y3413
+X3610Y6100G85X2100Y6100
T02
-X5000Y500
-X5400Y500
-X5800Y500
-X6200Y500
-X6600Y500
-X7000Y500
-X7400Y500
-X7800Y500
-X8200Y500
-X8600Y500
-X9000Y500
+X3610Y3900
+X3610Y1950
+X2140Y1950
+X2050Y3900
+T03
+G00X3610Y2925
+M15
+G01X2140Y2925
+M16
+G05
+
+X3600Y7100
+T04
+G00X600Y1700
+M15
+G03X1600Y700A1000
+G01X6600Y700
+G01X6600Y4100
+G03X5600Y5100A1000
+G01X600Y5100
+G01X600Y1700
+M16
+G05
M30
diff --git a/tests/expects/excellon_offset.txt b/tests/expects/excellon_offset.txt
index 2007248..41dbf3e 100644
--- a/tests/expects/excellon_offset.txt
+++ b/tests/expects/excellon_offset.txt
@@ -2,42 +2,38 @@ M48
FMAT,2
ICI,OFF
METRIC,TZ,000.000
-M71
-T01C0.100
-T02C0.200
+T01C0.600
+T02C0.700
+T03C0.800
+T04C1.000
%
+G90
+M71
T01
-X16000Y14500
-X16200Y14500
-X16400Y14500
-X16600Y14500
-X16800Y14500
-X17000Y14500
-X17200Y14500
-X17400Y14500
-X17600Y14500
-X17800Y14500
-X18000Y14500
-X18200Y14500
-X18400Y14500
-X18600Y14500
-X18800Y14500
-X19000Y14500
-X19200Y14500
-X19400Y14500
-X19600Y14500
-X19800Y14500
-X20000Y14500
+X15610Y7438
+X15610Y8413
+X14610Y11100G85X13100Y11100
T02
-X16000Y5500
-X16400Y5500
-X16800Y5500
-X17200Y5500
-X17600Y5500
-X18000Y5500
-X18400Y5500
-X18800Y5500
-X19200Y5500
-X19600Y5500
-X20000Y5500
+X14610Y8900
+X14610Y6950
+X13140Y6950
+X13050Y8900
+T03
+G00X14610Y7925
+M15
+G01X13140Y7925
+M16
+G05
+X14600Y12100
+T04
+G00X11600Y6700
+M15
+G03X12600Y5700A1000
+G01X17600Y5700
+G01X17600Y9100
+G03X16600Y10100A1000
+G01X11600Y10100
+G01X11600Y6700
+M16
+G05
M30
diff --git a/tests/expects/excellon_rotate.txt b/tests/expects/excellon_rotate.txt
index 2ef3540..9983909 100644
--- a/tests/expects/excellon_rotate.txt
+++ b/tests/expects/excellon_rotate.txt
@@ -2,42 +2,38 @@ M48
FMAT,2
ICI,OFF
METRIC,TZ,000.000
-M71
-T01C0.100
-T02C0.200
+T01C0.600
+T02C0.700
+T03C0.800
+T04C1.000
%
+G90
+M71
T01
-X5473Y7820
-X5660Y7888
-X5848Y7957
-X6036Y8025
-X6224Y8094
-X6412Y8162
-X6600Y8230
-X6788Y8299
-X6976Y8367
-X7164Y8436
-X7352Y8504
-X7540Y8572
-X7728Y8641
-X7916Y8709
-X8104Y8778
-X8292Y8846
-X8480Y8915
-X8668Y8983
-X8855Y9051
-X9043Y9120
-X9231Y9188
+X7521Y1051
+X7188Y1967
+X5329Y4150G85X3910Y3633
T02
-X8551Y-637
-X8927Y-500
-X9302Y-364
-X9678Y-227
-X10054Y-90
-X10430Y47
-X10806Y184
-X11182Y320
-X11558Y457
-X11934Y594
-X12309Y731
+X6082Y2082
+X6749Y250
+X5367Y-253
+X4616Y1549
+T03
+G00X6415Y1166
+M15
+G01X5034Y663
+M16
+G05
+X4978Y5086
+T04
+G00X4006Y-1014
+M15
+G03X5287Y-1612A1000
+G01X9986Y98
+G01X8823Y3293
+G03X7541Y3891A1000
+G01X2843Y2181
+G01X4006Y-1014
+M16
+G05
M30
diff --git a/tests/expects/excellon_save.txt b/tests/expects/excellon_save.txt
index a1d2ba8..6a22a7d 100644
--- a/tests/expects/excellon_save.txt
+++ b/tests/expects/excellon_save.txt
@@ -2,42 +2,38 @@ M48
FMAT,2
ICI,OFF
METRIC,TZ,000.000
-M71
-T01C0.100
-T02C0.200
+T01C0.600
+T02C0.700
+T03C0.800
+T04C1.000
%
+G90
+M71
T01
-X5000Y9500
-X5200Y9500
-X5400Y9500
-X5600Y9500
-X5800Y9500
-X6000Y9500
-X6200Y9500
-X6400Y9500
-X6600Y9500
-X6800Y9500
-X7000Y9500
-X7200Y9500
-X7400Y9500
-X7600Y9500
-X7800Y9500
-X8000Y9500
-X8200Y9500
-X8400Y9500
-X8600Y9500
-X8800Y9500
-X9000Y9500
+X4610Y2438
+X4610Y3413
+X3610Y6100G85X2100Y6100
T02
-X5000Y500
-X5400Y500
-X5800Y500
-X6200Y500
-X6600Y500
-X7000Y500
-X7400Y500
-X7800Y500
-X8200Y500
-X8600Y500
-X9000Y500
+X3610Y3900
+X3610Y1950
+X2140Y1950
+X2050Y3900
+T03
+G00X3610Y2925
+M15
+G01X2140Y2925
+M16
+G05
+X3600Y7100
+T04
+G00X600Y1700
+M15
+G03X1600Y700A1000
+G01X6600Y700
+G01X6600Y4100
+G03X5600Y5100A1000
+G01X600Y5100
+G01X600Y1700
+M16
+G05
M30
diff --git a/tests/expects/excellon_to_inch.txt b/tests/expects/excellon_to_inch.txt
index 8d31df0..6aea2e0 100644
--- a/tests/expects/excellon_to_inch.txt
+++ b/tests/expects/excellon_to_inch.txt
@@ -2,42 +2,38 @@ M48
FMAT,2
ICI,OFF
INCH,TZ,00.0000
-M72
-T01C0.0039
-T02C0.0078
+T01C0.0236
+T02C0.0275
+T03C0.0314
+T04C0.0393
%
+G90
+M72
T01
-X1969Y3740
-X2047Y3740
-X2126Y3740
-X2205Y3740
-X2283Y3740
-X2362Y3740
-X2441Y3740
-X2520Y3740
-X2598Y3740
-X2677Y3740
-X2756Y3740
-X2835Y3740
-X2913Y3740
-X2992Y3740
-X3071Y3740
-X3150Y3740
-X3228Y3740
-X3307Y3740
-X3386Y3740
-X3465Y3740
-X3543Y3740
+X1815Y960
+X1815Y1344
+X1421Y2402G85X827Y2402
T02
-X1969Y197
-X2126Y197
-X2283Y197
-X2441Y197
-X2598Y197
-X2756Y197
-X2913Y197
-X3071Y197
-X3228Y197
-X3386Y197
-X3543Y197
+X1421Y1535
+X1421Y768
+X843Y768
+X807Y1535
+T03
+G00X1421Y1152
+M15
+G01X843Y1152
+M16
+G05
+X1417Y2795
+T04
+G00X236Y669
+M15
+G03X630Y276A394
+G01X2598Y276
+G01X2598Y1614
+G03X2205Y2008A394
+G01X236Y2008
+G01X236Y669
+M16
+G05
M30
diff --git a/tests/expects/excellon_to_metric.txt b/tests/expects/excellon_to_metric.txt
index a634742..1bb4287 100644
--- a/tests/expects/excellon_to_metric.txt
+++ b/tests/expects/excellon_to_metric.txt
@@ -2,42 +2,38 @@ M48
FMAT,2
ICI,OFF
METRIC,TZ,000.000
-M71
-T01C0.099
-T02C0.198
+T01C0.599
+T02C0.698
+T03C0.797
+T04C0.998
%
+G90
+M71
T01
-X5001Y9500
-X5199Y9500
-X5400Y9500
-X5601Y9500
-X5799Y9500
-X5999Y9500
-X6200Y9500
-X6401Y9500
-X6599Y9500
-X6800Y9500
-X7000Y9500
-X7201Y9500
-X7399Y9500
-X7600Y9500
-X7800Y9500
-X8001Y9500
-X8199Y9500
-X8400Y9500
-X8600Y9500
-X8801Y9500
-X8999Y9500
+X4610Y2438
+X4610Y3414
+X3609Y6101G85X2101Y6101
T02
-X5001Y500
-X5400Y500
-X5799Y500
-X6200Y500
-X6599Y500
-X7000Y500
-X7399Y500
-X7800Y500
-X8199Y500
-X8600Y500
-X8999Y500
+X3609Y3899
+X3609Y1951
+X2141Y1951
+X2050Y3899
+T03
+G00X3609Y2926
+M15
+G01X2141Y2926
+M16
+G05
+X3599Y7099
+T04
+G00X599Y1699
+M15
+G03X1600Y701A1001
+G01X6599Y701
+G01X6599Y4100
+G03X5601Y5100A1001
+G01X599Y5100
+G01X599Y1699
+M16
+G05
M30