From 7e06f3a2f5870d4878f25e391372285263fe5ac6 Mon Sep 17 00:00:00 2001 From: Garret Fick Date: Sun, 10 Jul 2016 15:41:31 +0800 Subject: Workaround for bad excellon files that don't correctly set the mode --- gerber/excellon.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'gerber') diff --git a/gerber/excellon.py b/gerber/excellon.py index a0a639e..becf82d 100755 --- a/gerber/excellon.py +++ b/gerber/excellon.py @@ -665,19 +665,21 @@ class ExcellonParser(object): if y is not None: self.pos[1] += y - if self.state == 'DRILL': + if self.state == 'LINEAR' and self.drill_down: + if not self.active_tool: + self.active_tool = self._get_tool(1) + + self.hits.append(DrillSlot(self.active_tool, start, tuple(self.pos), DrillSlot.TYPE_ROUT)) + + elif self.state == 'DRILL' or self.state == 'HEADER': + # Yes, drills in the header doesn't follow the specification, but it there are many + # files like this if not self.active_tool: self.active_tool = self._get_tool(1) self.hits.append(DrillHit(self.active_tool, tuple(self.pos))) self.active_tool._hit() - elif self.state == 'LINEAR' and self.drill_down: - if not self.active_tool: - self.active_tool = self._get_tool(1) - - self.hits.append(DrillSlot(self.active_tool, start, tuple(self.pos), DrillSlot.TYPE_ROUT)) - else: self.statements.append(UnknownStmt.from_excellon(line)) -- cgit