summaryrefslogtreecommitdiff
path: root/gerber/excellon.py
diff options
context:
space:
mode:
authorHamilton Kibbe <hamilton.kibbe@gmail.com>2015-11-13 11:40:03 -0500
committerHamilton Kibbe <hamilton.kibbe@gmail.com>2015-11-13 11:40:03 -0500
commitebc85181975add0fd98c18441f029e9af696f237 (patch)
treec8e722390e4acfd89d7240b0d71753ba30783f7d /gerber/excellon.py
parent2208fe22052bf04816e5492cdcb4469c19644e4b (diff)
parentcead702f4d7094c3cec1419d6fd79b23cc4196c4 (diff)
downloadgerbonara-ebc85181975add0fd98c18441f029e9af696f237.tar.gz
gerbonara-ebc85181975add0fd98c18441f029e9af696f237.tar.bz2
gerbonara-ebc85181975add0fd98c18441f029e9af696f237.zip
Merge pull request #43 from curtacircuitos/excellon-with-no-tool-definition
Add fix to work with excellon with no tool definition.
Diffstat (limited to 'gerber/excellon.py')
-rwxr-xr-xgerber/excellon.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/gerber/excellon.py b/gerber/excellon.py
index c953e55..101c6ea 100755
--- a/gerber/excellon.py
+++ b/gerber/excellon.py
@@ -476,10 +476,27 @@ class ExcellonParser(object):
elif line[0] == 'T' and self.state != 'HEADER':
stmt = ToolSelectionStmt.from_excellon(line)
+ self.statements.append(stmt)
+
# T0 is used as END marker, just ignore
if stmt.tool != 0:
+ # FIXME: for weird files with no tools defined, original calc from gerbv
+ if stmt.tool not in self.tools:
+ if self._settings().units == "inch":
+ diameter = (16 + 8 * stmt.tool) / 1000.0;
+ else:
+ diameter = metric((16 + 8 * stmt.tool) / 1000.0);
+
+ tool = ExcellonTool(self._settings(), number=stmt.tool, diameter=diameter)
+ self.tools[tool.number] = tool
+
+ # FIXME: need to add this tool definition inside header to make sure it is properly written
+ for i, s in enumerate(self.statements):
+ if isinstance(s, ToolSelectionStmt) or isinstance(s, ExcellonTool):
+ self.statements.insert(i, tool)
+ break
+
self.active_tool = self.tools[stmt.tool]
- self.statements.append(stmt)
elif line[0] == 'R' and self.state != 'HEADER':
stmt = RepeatHoleStmt.from_excellon(line, self._settings())