From 3a78160638f514bc481cb59fe7d5fd2bcbb30d60 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Wed, 13 Jan 2021 15:32:08 -0300 Subject: [PATCH] More options to customize the excellon output. zeros_format, left_digits and right_digits options. --- CHANGELOG.md | 1 + kibot/out_excellon.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d00ad14c..faf97450 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support for KICAD_CONFIG_HOME defined from inside KiCad. - Now layers can be selected using the default KiCad names. - More control over the name of the drill files. +- More options to customize the excellon output. ### Changed - Now the default output name applies to the DRC and ERC report names. diff --git a/kibot/out_excellon.py b/kibot/out_excellon.py index e217fb43..84d2eea9 100644 --- a/kibot/out_excellon.py +++ b/kibot/out_excellon.py @@ -7,6 +7,10 @@ from pcbnew import EXCELLON_WRITER from .out_any_drill import AnyDrill from .macros import macros, document, output_class # noqa: F401 +ZF = { 'DECIMAL_FORMAT': EXCELLON_WRITER.DECIMAL_FORMAT, + 'SUPPRESS_LEADING': EXCELLON_WRITER.SUPPRESS_LEADING, + 'SUPPRESS_TRAILING': EXCELLON_WRITER.SUPPRESS_TRAILING, + 'KEEP_ZEROS': EXCELLON_WRITER.KEEP_ZEROS } class ExcellonOptions(AnyDrill): def __init__(self): @@ -20,11 +24,17 @@ class ExcellonOptions(AnyDrill): """ Use a minimal header in the file """ self.mirror_y_axis = False """ Invert the Y axis """ + self.zeros_format = 'DECIMAL_FORMAT' + """ [DECIMAL_FORMAT,SUPPRESS_LEADING,SUPPRESS_TRAILING,KEEP_ZEROS] How to handle the zeros """ + self.left_digits = 0 + """ number of digits for integer part of coordinates (0 is auto) """ + self.right_digits = 0 + """ number of digits for mantissa part of coordinates (0 is auto) """ def _configure_writer(self, board, offset): drill_writer = EXCELLON_WRITER(board) drill_writer.SetOptions(self.mirror_y_axis, self.minimal_header, offset, self.pth_and_npth_single_file) - drill_writer.SetFormat(self.metric_units, EXCELLON_WRITER.DECIMAL_FORMAT) + drill_writer.SetFormat(self.metric_units, ZF[self.zeros_format], self.left_digits, self.right_digits) self._unified_output = self.pth_and_npth_single_file return drill_writer, 'drl'