summaryrefslogtreecommitdiff
path: root/gerber
diff options
context:
space:
mode:
authorGarret Fick <garret@ficksworkshop.com>2016-03-26 18:18:16 +0800
committerGarret Fick <garret@ficksworkshop.com>2016-03-26 18:18:16 +0800
commit25515b8ec7016698431b74e5beac8ff2d6691f0b (patch)
tree81b4ed01131bc7c8fbbf6297ee4cc09e9080015a /gerber
parent82fed203100f99aa5df16897f874d8600df85b6e (diff)
downloadgerbonara-25515b8ec7016698431b74e5beac8ff2d6691f0b.tar.gz
gerbonara-25515b8ec7016698431b74e5beac8ff2d6691f0b.tar.bz2
gerbonara-25515b8ec7016698431b74e5beac8ff2d6691f0b.zip
Correctly render M15 slot holes
Diffstat (limited to 'gerber')
-rwxr-xr-xgerber/excellon.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/gerber/excellon.py b/gerber/excellon.py
index f9bb18a..02709fd 100755
--- a/gerber/excellon.py
+++ b/gerber/excellon.py
@@ -345,6 +345,7 @@ class ExcellonParser(object):
self.hits = []
self.active_tool = None
self.pos = [0., 0.]
+ self.drill_down = False
# Default for lated is None, which means we don't know
self.plated = ExcellonTool.PLATED_UNKNOWN
if settings is not None:
@@ -453,12 +454,15 @@ class ExcellonParser(object):
elif line[:3] == 'M15':
self.statements.append(ZAxisRoutPositionStmt())
+ self.drill_down = True
elif line[:3] == 'M16':
self.statements.append(RetractWithClampingStmt())
+ self.drill_down = False
elif line[:3] == 'M17':
self.statements.append(RetractWithoutClampingStmt())
+ self.drill_down = False
elif line[:3] == 'M30':
stmt = EndOfProgramStmt.from_excellon(line, self._settings())
@@ -491,6 +495,9 @@ class ExcellonParser(object):
stmt = CoordinateStmt.from_excellon(line[3:], self._settings())
stmt.mode = self.state
+
+ # The start position is where we were before the rout command
+ start = (self.pos[0], self.pos[1])
x = stmt.x
y = stmt.y
@@ -505,9 +512,20 @@ class ExcellonParser(object):
self.pos[0] += x
if y is not None:
self.pos[1] += y
-
+
+ # Our ending position
+ end = (self.pos[0], self.pos[1])
+
+ if self.drill_down:
+ if not self.active_tool:
+ self.active_tool = self._get_tool(1)
+
+ self.hits.append(DrillSlot(self.active_tool, start, end))
+ self.active_tool._hit()
+
elif line[:3] == 'G05':
self.statements.append(DrillModeStmt())
+ self.drill_down = False
self.state = 'DRILL'
elif 'INCH' in line or 'METRIC' in line: