From 8a0af1a043032b49aed1338287585ed7936482be Mon Sep 17 00:00:00 2001 From: Benny Megidish Date: Tue, 26 Sep 2023 23:03:33 +0300 Subject: [PATCH] chore: rename to exclude DNP #54 --- plugins/options.py | 2 +- plugins/plugin.py | 12 ++++++------ plugins/process.py | 10 +++++----- plugins/thread.py | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/plugins/options.py b/plugins/options.py index 221bf2d..940eb3c 100644 --- a/plugins/options.py +++ b/plugins/options.py @@ -1,2 +1,2 @@ -IGNORE_DNP_OPT = "IGNORE DNP" +EXCLUDE_DNP_OPT = "EXCLUDE DNP" OUTPUT_NAME_OPT = "OUTPUT NAME" \ No newline at end of file diff --git a/plugins/plugin.py b/plugins/plugin.py index 6a5bdf0..bbdca07 100644 --- a/plugins/plugin.py +++ b/plugins/plugin.py @@ -4,7 +4,7 @@ from .thread import ProcessThread from .events import StatusEvent -from .options import IGNORE_DNP_OPT +from .options import EXCLUDE_DNP_OPT # WX GUI form that show the plugin progress @@ -28,8 +28,8 @@ def __init__(self): self.mOptionsLabel = wx.StaticText(self, label='Options:') # self.mOptionsSeparator = wx.StaticLine(self) - self.mIgnoreDnpCheckbox = wx.CheckBox(self, label='Ignore DNP components') - self.mIgnoreDnpCheckbox.SetValue(False) + self.mExcludeDnpCheckbox = wx.CheckBox(self, label='Exclude DNP components') + self.mExcludeDnpCheckbox.SetValue(False) self.mGenerateButton = wx.Button(self, label='Generate', size=wx.Size(600, 60)) @@ -44,7 +44,7 @@ def __init__(self): boxSizer.Add(self.mOptionsLabel, 0, wx.ALL, 5) # boxSizer.Add(self.mOptionsSeparator, 0, wx.ALL, 5) - boxSizer.Add(self.mIgnoreDnpCheckbox, 0, wx.ALL, 5) + boxSizer.Add(self.mExcludeDnpCheckbox, 0, wx.ALL, 5) boxSizer.Add(self.mGaugeStatus, 0, wx.ALL, 5) boxSizer.Add(self.mGenerateButton, 0, wx.ALL, 5) @@ -57,9 +57,9 @@ def __init__(self): def onGenerateButtonClick(self, event): options = dict() - options[IGNORE_DNP_OPT] = self.mIgnoreDnpCheckbox.GetValue() + options[EXCLUDE_DNP_OPT] = self.mExcludeDnpCheckbox.GetValue() - self.mIgnoreDnpCheckbox.Hide() + self.mExcludeDnpCheckbox.Hide() self.mOptionsLabel.Hide() self.mGenerateButton.Hide() self.mGaugeStatus.Show() diff --git a/plugins/process.py b/plugins/process.py index c195577..e19bcaf 100644 --- a/plugins/process.py +++ b/plugins/process.py @@ -138,7 +138,7 @@ def generate_netlist(self, temp_dir): netlist_writer = pcbnew.IPC356D_WRITER(self.board) netlist_writer.Write(os.path.join(temp_dir, netlistFileName)) - def generate_tables(self, temp_dir, ignore_dnp): + def generate_tables(self, temp_dir, exclude_dnp): '''Generate the data tables.''' if hasattr(self.board, 'GetModules'): footprints = list(self.board.GetModules()) @@ -177,8 +177,9 @@ def generate_tables(self, temp_dir, ignore_dnp): # 2: 'smt' # }.get(footprint.GetAttributes()) - if not footprint.GetAttributes() & pcbnew.FP_EXCLUDE_FROM_POS_FILES or \ - not (ignore_dnp and footprint.GetValue().upper() == 'DNP'): + skip_footprint = exclude_dnp and (footprint.HasProperty('dnp') or footprint.GetValue().upper() == 'DNP') + + if not (footprint.GetAttributes() & pcbnew.FP_EXCLUDE_FROM_POS_FILES) and not skip_footprint: # append unique ID if duplicate footprint designator unique_id = "" if footprint_designators[footprint.GetReference()] > 1: @@ -213,8 +214,7 @@ def generate_tables(self, temp_dir, ignore_dnp): 'Layer': layer, }) - if not footprint.GetAttributes() & pcbnew.FP_EXCLUDE_FROM_BOM or \ - not (ignore_dnp and footprint.GetValue().upper() == 'DNP'): + if not (footprint.GetAttributes() & pcbnew.FP_EXCLUDE_FROM_BOM) and not skip_footprint: # append unique ID if we are dealing with duplicate bom designator unique_id = "" if bom_designators[footprint.GetReference()] > 1: diff --git a/plugins/thread.py b/plugins/thread.py index 8088409..90741b1 100644 --- a/plugins/thread.py +++ b/plugins/thread.py @@ -53,7 +53,7 @@ def run(self): # generate data tables self.progress(50) - self.process_manager.generate_tables(temp_dir, self.options[IGNORE_DNP_OPT]) + self.process_manager.generate_tables(temp_dir, self.options[EXCLUDE_DNP_OPT]) # generate pick and place file self.progress(60)