From e1378eea49efb93eb2efedd1dee31f22e21a46ae Mon Sep 17 00:00:00 2001 From: Adrian Studer Date: Thu, 21 Nov 2024 04:57:43 -0800 Subject: [PATCH] feat: add option to enable/disable plotting of all active layers (#176) * Add option to enable/disable export of all active layers. Disabling that option will only export commonly used fabrication layers. Addresses issue #172 * move definition of standard layers to config.py --- plugins/config.py | 15 ++++++++++++++- plugins/options.py | 1 + plugins/plugin.py | 9 +++++++-- plugins/process.py | 5 ++--- plugins/thread.py | 3 ++- 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/plugins/config.py b/plugins/config.py index de2e05b..35f92a6 100644 --- a/plugins/config.py +++ b/plugins/config.py @@ -10,4 +10,17 @@ gerberArchiveName = 'gerbers.zip' outputFolder = 'production' bomRowLimit = 200 -optionsFileName = 'fabrication-toolkit-options.json' \ No newline at end of file +optionsFileName = 'fabrication-toolkit-options.json' + +standardLayers = [ pcbnew.F_Cu, pcbnew.B_Cu, + pcbnew.In1_Cu, pcbnew.In2_Cu, pcbnew.In3_Cu, pcbnew.In4_Cu, pcbnew.In5_Cu, + pcbnew.In6_Cu, pcbnew.In7_Cu, pcbnew.In8_Cu, pcbnew.In9_Cu, pcbnew.In10_Cu, + pcbnew.In11_Cu, pcbnew.In12_Cu, pcbnew.In13_Cu, pcbnew.In14_Cu, pcbnew.In15_Cu, + pcbnew.In16_Cu, pcbnew.In17_Cu, pcbnew.In18_Cu, pcbnew.In19_Cu, pcbnew.In20_Cu, + pcbnew.In21_Cu, pcbnew.In22_Cu, pcbnew.In23_Cu, pcbnew.In24_Cu, pcbnew.In25_Cu, + pcbnew.In26_Cu, pcbnew.In27_Cu, pcbnew.In28_Cu, pcbnew.In29_Cu, pcbnew.In30_Cu, + pcbnew.F_SilkS, pcbnew.B_SilkS, + pcbnew.F_Mask, pcbnew.B_Mask, + pcbnew.F_Paste, pcbnew.B_Paste, + pcbnew.Edge_Cuts + ] diff --git a/plugins/options.py b/plugins/options.py index a2d91c4..27ae033 100644 --- a/plugins/options.py +++ b/plugins/options.py @@ -4,4 +4,5 @@ EXCLUDE_DNP_OPT = "EXCLUDE DNP" OUTPUT_NAME_OPT = "OUTPUT NAME" EXTEND_EDGE_CUT_OPT = "EXTEND_EDGE_CUT" ALTERNATIVE_EDGE_CUT_OPT = "ALTERNATIVE_EDGE_CUT" +ALL_ACTIVE_LAYERS_OPT = "ALL_ACTIVE_LAYERS" EXTRA_LAYERS = "EXTRA_LAYERS" \ No newline at end of file diff --git a/plugins/plugin.py b/plugins/plugin.py index 91b9bb8..d94d94f 100644 --- a/plugins/plugin.py +++ b/plugins/plugin.py @@ -4,7 +4,7 @@ import pcbnew # type: ignore from .thread import ProcessThread from .events import StatusEvent -from .options import AUTO_FILL_OPT, AUTO_TRANSLATE_OPT, EXCLUDE_DNP_OPT, EXTEND_EDGE_CUT_OPT, ALTERNATIVE_EDGE_CUT_OPT, EXTRA_LAYERS +from .options import AUTO_FILL_OPT, AUTO_TRANSLATE_OPT, EXCLUDE_DNP_OPT, EXTEND_EDGE_CUT_OPT, ALTERNATIVE_EDGE_CUT_OPT, EXTRA_LAYERS, ALL_ACTIVE_LAYERS_OPT from .utils import load_user_options, save_user_options, get_layer_names @@ -29,6 +29,7 @@ class KiCadToJLCForm(wx.Frame): userOptions = load_user_options({ EXTRA_LAYERS: "", + ALL_ACTIVE_LAYERS_OPT: False, EXTEND_EDGE_CUT_OPT: False, ALTERNATIVE_EDGE_CUT_OPT: False, AUTO_TRANSLATE_OPT: True, @@ -45,7 +46,8 @@ class KiCadToJLCForm(wx.Frame): self.mAdditionalLayersControl.AutoComplete(layers) self.mAdditionalLayersControl.Enable() self.mAdditionalLayersControl.SetValue(userOptions[EXTRA_LAYERS]) - + self.mAllActiveLayersCheckbox = wx.CheckBox(self, label='Plot all active layers') + self.mAllActiveLayersCheckbox.SetValue(userOptions[ALL_ACTIVE_LAYERS_OPT]) self.mExtendEdgeCutsCheckbox = wx.CheckBox(self, label='Set User.1 as V-Cut layer') self.mExtendEdgeCutsCheckbox.SetValue(userOptions[EXTEND_EDGE_CUT_OPT]) self.mAlternativeEdgeCutsCheckbox = wx.CheckBox(self, label='Use User.2 for alternative Edge-Cut layer') @@ -70,6 +72,7 @@ class KiCadToJLCForm(wx.Frame): boxSizer.Add(self.mOptionsLabel, 0, wx.ALL, 5) # boxSizer.Add(self.mOptionsSeparator, 0, wx.ALL, 5) boxSizer.Add(self.mAdditionalLayersControl, 0, wx.ALL, 5) + boxSizer.Add(self.mAllActiveLayersCheckbox, 0, wx.ALL, 5) boxSizer.Add(self.mExtendEdgeCutsCheckbox, 0, wx.ALL, 5) boxSizer.Add(self.mAlternativeEdgeCutsCheckbox, 0, wx.ALL, 5) boxSizer.Add(self.mAutomaticTranslationCheckbox, 0, wx.ALL, 5) @@ -98,6 +101,7 @@ class KiCadToJLCForm(wx.Frame): def onGenerateButtonClick(self, event): options = dict() options[EXTRA_LAYERS] = self.mAdditionalLayersControl.GetValue() + options[ALL_ACTIVE_LAYERS_OPT] = self.mAllActiveLayersCheckbox.GetValue() options[EXTEND_EDGE_CUT_OPT] = self.mExtendEdgeCutsCheckbox.GetValue() options[ALTERNATIVE_EDGE_CUT_OPT] = self.mAlternativeEdgeCutsCheckbox.GetValue() options[AUTO_TRANSLATE_OPT] = self.mAutomaticTranslationCheckbox.GetValue() @@ -108,6 +112,7 @@ class KiCadToJLCForm(wx.Frame): self.mOptionsLabel.Hide() self.mAdditionalLayersControl.Hide() + self.mAllActiveLayersCheckbox.Hide() self.mExtendEdgeCutsCheckbox.Hide() self.mAlternativeEdgeCutsCheckbox.Hide() self.mAutomaticTranslationCheckbox.Hide() diff --git a/plugins/process.py b/plugins/process.py index bdd8afb..e85efd1 100644 --- a/plugins/process.py +++ b/plugins/process.py @@ -17,7 +17,6 @@ from .utils import footprint_has_field, footprint_get_field, get_plot_plan # Application definitions. from .config import * - class ProcessManager: def __init__(self): self.board = pcbnew.GetBoard() @@ -42,7 +41,7 @@ class ProcessManager: # Finally rebuild the connectivity db self.board.BuildConnectivity() - def generate_gerber(self, temp_dir, extra_layers, extend_edge_cuts, alternative_edge_cuts): + def generate_gerber(self, temp_dir, extra_layers, extend_edge_cuts, alternative_edge_cuts, all_active_layers): '''Generate the Gerber files.''' settings = self.board.GetDesignSettings() settings.m_SolderMaskMargin = 50000 @@ -74,7 +73,7 @@ class ProcessManager: extra_layers = [] for layer_info in get_plot_plan(self.board): - if self.board.IsLayerEnabled(layer_info[1]) or layer_info[0] in extra_layers: + if (self.board.IsLayerEnabled(layer_info[1]) and (all_active_layers or layer_info[1] in standardLayers)) or layer_info[0] in extra_layers: plot_controller.SetLayer(layer_info[1]) plot_controller.OpenPlotfile(layer_info[0], pcbnew.PLOT_FORMAT_GERBER, layer_info[2]) diff --git a/plugins/thread.py b/plugins/thread.py index 7b8a463..6a27cd8 100644 --- a/plugins/thread.py +++ b/plugins/thread.py @@ -40,7 +40,8 @@ class ProcessThread(Thread): # generate gerber self.progress(20) - self.process_manager.generate_gerber(temp_dir_gerber, self.options[EXTRA_LAYERS], self.options[EXTEND_EDGE_CUT_OPT], self.options[ALTERNATIVE_EDGE_CUT_OPT]) + self.process_manager.generate_gerber(temp_dir_gerber, self.options[EXTRA_LAYERS], self.options[EXTEND_EDGE_CUT_OPT], + self.options[ALTERNATIVE_EDGE_CUT_OPT], self.options[ALL_ACTIVE_LAYERS_OPT]) # generate drill file self.progress(30)