Skip to content

Commit

Permalink
feat: ignore dnp if value == DNP and option is set
Browse files Browse the repository at this point in the history
  • Loading branch information
bennymeg committed Sep 26, 2023
1 parent 355f3c3 commit d3cb950
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions plugins/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def __init__(self):
size=wx.DefaultSize,
style=wx.DEFAULT_DIALOG_STYLE)

# self.app = wx.PySimpleApp()
icon = wx.Icon(os.path.join(os.path.dirname(__file__), 'icon.png'))
self.SetIcon(icon)
self.SetBackgroundColour(wx.LIGHT_GREY)
Expand Down
17 changes: 11 additions & 6 deletions plugins/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ def generate_netlist(self, temp_dir):
netlist_writer = pcbnew.IPC356D_WRITER(self.board)
netlist_writer.Write(os.path.join(temp_dir, netlistFileName))

def generate_positions(self, temp_dir, ignore_dnp):
'''Generate the position files.'''
def generate_tables(self, temp_dir, ignore_dnp):
'''Generate the data tables.'''
if hasattr(self.board, 'GetModules'):
footprints = list(self.board.GetModules())
else:
Expand Down Expand Up @@ -177,7 +177,8 @@ def generate_positions(self, temp_dir, ignore_dnp):
# 2: 'smt'
# }.get(footprint.GetAttributes())

if not footprint.GetAttributes() & pcbnew.FP_EXCLUDE_FROM_POS_FILES:
if not footprint.GetAttributes() & pcbnew.FP_EXCLUDE_FROM_POS_FILES or \
not (ignore_dnp and footprint.GetValue().upper() == 'DNP'):
# append unique ID if duplicate footprint designator
unique_id = ""
if footprint_designators[footprint.GetReference()] > 1:
Expand Down Expand Up @@ -212,7 +213,8 @@ def generate_positions(self, temp_dir, ignore_dnp):
'Layer': layer,
})

if not footprint.GetAttributes() & pcbnew.FP_EXCLUDE_FROM_BOM:
if not footprint.GetAttributes() & pcbnew.FP_EXCLUDE_FROM_BOM or \
not (ignore_dnp and footprint.GetValue().upper() == 'DNP'):
# append unique ID if we are dealing with duplicate bom designator
unique_id = ""
if bom_designators[footprint.GetReference()] > 1:
Expand Down Expand Up @@ -243,6 +245,8 @@ def generate_positions(self, temp_dir, ignore_dnp):
'LCSC Part #': self._get_mpn_from_footprint(footprint),
})

def generate_positions(self, temp_dir):
'''Generate the position file.'''
if len(self.components) > 0:
with open((os.path.join(temp_dir, placementFileName)), 'w', newline='', encoding='utf-8-sig') as outfile:
csv_writer = csv.writer(outfile)
Expand All @@ -254,7 +258,8 @@ def generate_positions(self, temp_dir, ignore_dnp):
if ('**' not in component['Designator']):
csv_writer.writerow(component.values())

def generate_bom(self, temp_dir, ignore_dnp):
def generate_bom(self, temp_dir):
'''Generate the bom file.'''
if len(self.bom) > 0:
with open((os.path.join(temp_dir, bomFileName)), 'w', newline='', encoding='utf-8-sig') as outfile:
csv_writer = csv.writer(outfile)
Expand All @@ -268,7 +273,7 @@ def generate_bom(self, temp_dir, ignore_dnp):
csv_writer.writerow(component.values())

def generate_archive(self, temp_dir, temp_file):
'''Generate the files.'''
'''Generate the archive file.'''
temp_file = shutil.make_archive(temp_file, 'zip', temp_dir)
temp_file = shutil.move(temp_file, temp_dir)

Expand Down
16 changes: 10 additions & 6 deletions plugins/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,20 @@ def run(self):
self.progress(40)
self.process_manager.generate_netlist(temp_dir)

# generate pick and place file
# generate data tables
self.progress(50)
self.process_manager.generate_positions(temp_dir, self.options[IGNORE_DNP_OPT])
self.process_manager.generate_tables(temp_dir, self.options[IGNORE_DNP_OPT])

# generate BOM file
# generate pick and place file
self.progress(60)
self.process_manager.generate_bom(temp_dir, self.options[IGNORE_DNP_OPT])
self.process_manager.generate_positions(temp_dir)

# generate BOM file
self.progress(70)
self.process_manager.generate_bom(temp_dir)

# generate production archive
self.progress(75)
self.progress(85)
temp_file = self.process_manager.generate_archive(temp_dir + "_g", temp_file)
shutil.move(temp_file, temp_dir)
shutil.rmtree(temp_dir + "_g")
Expand All @@ -80,7 +84,7 @@ def run(self):
break
read_so_far += len(data)
percent = read_so_far * 1e2 / total_size
self.progress(75 + percent / 8)
self.progress(85 + percent / 8)

# generate gerber name
title_block = self.process_manager.board.GetTitleBlock()
Expand Down

0 comments on commit d3cb950

Please sign in to comment.