summaryrefslogtreecommitdiff
path: root/gerbonara/gerber/excellon.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2022-01-22 15:00:05 +0100
committerjaseg <git@jaseg.de>2022-01-22 15:00:05 +0100
commit7cf41c6a72e52a63b4f4d4497732a72d6623eec8 (patch)
treeb58607dd787173da641e21b678753855358495e5 /gerbonara/gerber/excellon.py
parentb85e8b0065c1b90159970ed8139f0747e953eb3f (diff)
downloadgerbonara-7cf41c6a72e52a63b4f4d4497732a72d6623eec8.tar.gz
gerbonara-7cf41c6a72e52a63b4f4d4497732a72d6623eec8.tar.bz2
gerbonara-7cf41c6a72e52a63b4f4d4497732a72d6623eec8.zip
Fix a few more tests
Diffstat (limited to 'gerbonara/gerber/excellon.py')
-rwxr-xr-xgerbonara/gerber/excellon.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/gerbonara/gerber/excellon.py b/gerbonara/gerber/excellon.py
index a42a667..4887245 100755
--- a/gerbonara/gerber/excellon.py
+++ b/gerbonara/gerber/excellon.py
@@ -194,12 +194,20 @@ class ExcellonFile(CamFile):
tool_map = { id(obj.tool): obj.tool for obj in self.objects }
tools = sorted(tool_map.items(), key=lambda id_tool: (id_tool[1].plated, id_tool[1].diameter, id_tool[1].depth_offset))
tools = { tool_id: index for index, (tool_id, _tool) in enumerate(tools, start=1) }
+ # FIXME dedup tools
+
+ mixed_plating = (len({ tool.plated for tool in tool_map.values() }) > 1)
+ if mixed_plating:
+ warnings.warn('Multiple plating values in same file. Will use non-standard Altium comment syntax to indicate hole plating.')
if tools and max(tools.values()) >= 100:
warnings.warn('More than 99 tools defined. Some programs may not like three-digit tool indices.', SyntaxWarning)
for tool_id, index in tools.items():
- yield f'T{index:02d}' + tool_map[tool_id].to_xnc(settings)
+ tool = tool_map[tool_id]
+ if mixed_plating:
+ yield ';TYPE=PLATED' if tool.plated else ';TYPE=NON_PLATED'
+ yield f'T{index:02d}' + tool.to_xnc(settings)
yield '%'
@@ -325,6 +333,8 @@ class ExcellonParser(object):
# from the excellon file, the caller must pass in an already filled-out FileSettings object.
if settings is None:
self.settings = FileSettings(number_format=(None, None))
+ else:
+ self.settings = settings
self.program_state = None
self.interpolation_mode = InterpMode.LINEAR
self.tools = {}