diff --git a/eeschema/plugins/python_scripts/bom_csv_grouped_by_value.py b/eeschema/plugins/python_scripts/bom_csv_grouped_by_value.py index c18539d5bf..b6f58a46ec 100644 --- a/eeschema/plugins/python_scripts/bom_csv_grouped_by_value.py +++ b/eeschema/plugins/python_scripts/bom_csv_grouped_by_value.py @@ -73,7 +73,7 @@ except IOError: # subset the components to those wanted in the BOM, controlled # by block in kicad_netlist_reader.py -components = net.getInterestingComponents() +components = net.getInterestingComponents( excludeBOM=True ) compfields = net.gatherComponentFieldUnion(components) partfields = net.gatherLibPartFieldUnion() diff --git a/eeschema/plugins/python_scripts/bom_csv_sorted_by_ref.py b/eeschema/plugins/python_scripts/bom_csv_sorted_by_ref.py index 58042f448b..6441867567 100644 --- a/eeschema/plugins/python_scripts/bom_csv_sorted_by_ref.py +++ b/eeschema/plugins/python_scripts/bom_csv_sorted_by_ref.py @@ -51,7 +51,7 @@ def writerow( acsvwriter, columns ): utf8row.append( fromNetlistText( str(col) ) ) acsvwriter.writerow( utf8row ) -components = net.getInterestingComponents() +components = net.getInterestingComponents( excludeBOM=True ) # Output a field delimited header line writerow( out, ['Source:', net.getSource()] ) diff --git a/eeschema/plugins/python_scripts/bom_html_grouped_by_value.py b/eeschema/plugins/python_scripts/bom_html_grouped_by_value.py index c9bf546d6e..281bbadabb 100644 --- a/eeschema/plugins/python_scripts/bom_html_grouped_by_value.py +++ b/eeschema/plugins/python_scripts/bom_html_grouped_by_value.py @@ -56,7 +56,7 @@ except IOError: print(__file__, ":", e, file=sys.stderr) f = sys.stdout -components = net.getInterestingComponents() +components = net.getInterestingComponents( excludeBOM=True ) # Output a set of rows for a header providing general information html = html.replace('', net.getSource()) diff --git a/eeschema/plugins/python_scripts/bom_html_with_advanced_grouping.py b/eeschema/plugins/python_scripts/bom_html_with_advanced_grouping.py index 596a6d6c80..3c4c7e55d8 100644 --- a/eeschema/plugins/python_scripts/bom_html_with_advanced_grouping.py +++ b/eeschema/plugins/python_scripts/bom_html_with_advanced_grouping.py @@ -103,7 +103,7 @@ row += "Description" + "Vendor" html = html.replace('', row + "") -components = net.getInterestingComponents() +components = net.getInterestingComponents( excludeBOM=True ) # Get all of the components in groups of matching parts + values # (see kicad_netlist_reader.py) diff --git a/eeschema/plugins/python_scripts/bom_txt_sorted_by_ref.py b/eeschema/plugins/python_scripts/bom_txt_sorted_by_ref.py index e50974c301..2ad3cb90b4 100644 --- a/eeschema/plugins/python_scripts/bom_txt_sorted_by_ref.py +++ b/eeschema/plugins/python_scripts/bom_txt_sorted_by_ref.py @@ -52,7 +52,7 @@ def writerow( acsvwriter, columns ): utf8row.append( fromNetlistText(txt) ) acsvwriter.writerow( utf8row ) -components = net.getInterestingComponents() +components = net.getInterestingComponents( excludeBOM=True ) # Output a field delimited header line writerow( out, ['Source:', net.getSource()] ) diff --git a/eeschema/plugins/python_scripts/kicad_netlist_reader.py b/eeschema/plugins/python_scripts/kicad_netlist_reader.py index 52138c6072..e53c65e998 100644 --- a/eeschema/plugins/python_scripts/kicad_netlist_reader.py +++ b/eeschema/plugins/python_scripts/kicad_netlist_reader.py @@ -405,6 +405,45 @@ class comp(): def getRef(self): return self.element.get("comp", "ref") + ''' + Return true if the component has the DNP property set + ''' + def getDNP(self): + for child in self.element.getChildren( "property"): + try: + if child.attributes['name'] == 'dnp': + return True + except KeyError: + continue + + return False + + ''' + Return true if the component has the exclude from BOM property set + ''' + def getExcludeFromBOM(self): + for child in self.element.getChildren( "property"): + try: + if child.attributes['name'] == 'exclude_from_bom': + return True + except KeyError: + continue + + return False + + ''' + Return true if the component has the exclude from Board property set + ''' + def getExcludeFromBoard(self): + for child in self.element.getChildren( "property"): + try: + if child.attributes['name'] == 'exclude_from_board': + return True + except KeyError: + continue + + return False + ''' return the footprint name. if empty and aLibraryToo = True, return the footprint name from libary @@ -634,7 +673,7 @@ class netlist(): return ret # this is a python 'set' - def getInterestingComponents(self): + def getInterestingComponents(self, excludeBOM=False, excludeBoard=False, DNP=False): """Return a subset of all components, those that should show up in the BOM. Omit those that should not, by consulting the blacklists: excluded_values, excluded_refs, and excluded_footprints, which hold one @@ -667,23 +706,26 @@ class netlist(): for refs in self.excluded_references: if refs.match(c.getRef()): exclude = True - break; + break if not exclude: for vals in self.excluded_values: if vals.match(c.getValue()): exclude = True - break; + break if not exclude: for mods in self.excluded_footprints: if mods.match(c.getFootprint()): exclude = True - break; + break - if not exclude: - # This is a fairly personal way to flag DNS (Do Not Stuff). NU for - # me means Normally Uninstalled. You can 'or in' another expression here. - if c.getField( "Installed" ) == 'NU': - exclude = True + if excludeBOM and c.getExcludeFromBOM(): + exclude = True + + if excludeBoard and c.getExcludeFromBoard(): + exclude = True + + if DNP and c.getDNP(): + exclude = True if not exclude: ret.append(c) @@ -716,6 +758,7 @@ class netlist(): # Make sure to start off will all components ungrouped to begin with for c in components: c.grouped = False + c.getExcludeFromBOM() # Group components based on the value, library and part identifiers for c in components: