diff options
author | Paulo Henrique Silva <ph.silva@gmail.com> | 2015-11-13 13:18:50 -0200 |
---|---|---|
committer | Paulo Henrique Silva <ph.silva@gmail.com> | 2015-11-13 13:18:50 -0200 |
commit | cead702f4d7094c3cec1419d6fd79b23cc4196c4 (patch) | |
tree | c8e722390e4acfd89d7240b0d71753ba30783f7d /gerber/excellon.py | |
parent | 2208fe22052bf04816e5492cdcb4469c19644e4b (diff) | |
download | gerbonara-cead702f4d7094c3cec1419d6fd79b23cc4196c4.tar.gz gerbonara-cead702f4d7094c3cec1419d6fd79b23cc4196c4.tar.bz2 gerbonara-cead702f4d7094c3cec1419d6fd79b23cc4196c4.zip |
Add fix to work with excellon with no tool definition.
I found out that Proteus generate some strange Excellon without any tool definition.
Gerbv renders it correctly and after digging in I found the heuristic that they use
to "guess" the tool diameter. This change replicates this behavior on pcb-tools.
Diffstat (limited to 'gerber/excellon.py')
-rwxr-xr-x | gerber/excellon.py | 19 |
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())
|