summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgerber/excellon.py2
-rw-r--r--gerber/excellon_statements.py14
-rw-r--r--gerber/primitives.py2
3 files changed, 15 insertions, 3 deletions
diff --git a/gerber/excellon.py b/gerber/excellon.py
index 4317e41..4456329 100755
--- a/gerber/excellon.py
+++ b/gerber/excellon.py
@@ -461,6 +461,8 @@ class ExcellonParser(object):
stmt = UnitStmt.from_excellon(line)
self.units = stmt.units
self.zeros = stmt.zeros
+ if stmt.format:
+ self.format = stmt.format
self.statements.append(stmt)
elif line[:3] == 'M71' or line [:3] == 'M72':
diff --git a/gerber/excellon_statements.py b/gerber/excellon_statements.py
index e10308a..d2ba233 100644
--- a/gerber/excellon_statements.py
+++ b/gerber/excellon_statements.py
@@ -601,14 +601,24 @@ class UnitStmt(ExcellonStatement):
def from_excellon(cls, line, **kwargs):
units = 'inch' if 'INCH' in line else 'metric'
zeros = 'leading' if 'LZ' in line else 'trailing'
- return cls(units, zeros, **kwargs)
+ if '0000.00' in line:
+ format = (4, 2)
+ elif '000.000' in line:
+ format = (3, 3)
+ elif '00.0000' in line:
+ format = (2, 4)
+ else:
+ format = None
+ return cls(units, zeros, format, **kwargs)
- def __init__(self, units='inch', zeros='leading', **kwargs):
+ def __init__(self, units='inch', zeros='leading', format=None, **kwargs):
super(UnitStmt, self).__init__(**kwargs)
self.units = units.lower()
self.zeros = zeros
+ self.format = format
def to_excellon(self, settings=None):
+ # TODO This won't export the invalid format statement if it exists
stmt = '%s,%s' % ('INCH' if self.units == 'inch' else 'METRIC',
'LZ' if self.zeros == 'leading'
else 'TZ')
diff --git a/gerber/primitives.py b/gerber/primitives.py
index b0e17e9..81c5837 100644
--- a/gerber/primitives.py
+++ b/gerber/primitives.py
@@ -827,7 +827,7 @@ class Region(Primitive):
@property
def bounding_box(self):
- xlims, ylims = zip(*[p.bounding_box for p in self.primitives])
+ xlims, ylims = zip(*[p.bounding_box_no_aperture for p in self.primitives])
minx, maxx = zip(*xlims)
miny, maxy = zip(*ylims)
min_x = min(minx)