Exclude page from BOM

Hi guys

I’ve been searching the forum for an hour now and cannot seem to find a solution.

I have multi-page project which consists of 9 different pages and 3 PCBs. I’d like to create 3 separate BOMs for 3 PCBs as these will be handled differently.
Motherboard PCB is contained on 7 pages of schematic and 2 pages are separate PCBs.
All parts on all pages are prefixed with page numbers (eg. resistors on page 5 are all numbered R500, R501, R502… etc…)

Is there a way I can exclude a page while generating BOM? Did someone already generated a script with that functionality?

If not it seems that I might have to write it myself.

Any input is appreciated.

I managed to hack something quickly just by adding below 3 lines to bom_csv_grouped_by_value.py script in /usr/share/kicad/plugins

# Output all the interesting components individually first:
row = []
for c in components:
    # Added: do not add components from pages 5 and 7
    if re.match(r'^\D{1,3}[5|7]\d+', c.getRef()):
        print('Removed: ', c.getRef())
        continue
    #################
    del row[:]
    row.append('')                                      # item is blank in individual table
    row.append('')                                      # Qty is always 1, why print it
...........

This script will print all skipped references:

"/usr/bin/python3" "/usr/share/kicad/plugins/bom_csv_group_by_value_exclude_pages.py" "/home/tdarlic/Documents/Kicad/projects/some_pcb/some_pcb.xml" "/home/tdarlic/Documents/Kicad/projects/some_pcb/some_pcb.csv"
Success.
Removed:  AN501
Removed:  C501
Removed:  C502
Removed:  C503
Removed:  C504
Removed:  C505
........

I might return to it later to get it more used friendly so one could choose which pages to include and which to skip.

1 Like

OK
I’ve found even better place for placing regex for references that need to be excluded.
This is in kicad_netlist_reader.py file in /usr/share/kicad/plugins directory.
I needed to read trough comments to figure it out. There is a variable called excluded_references and I just added regex for all components that I wanted to skip.

# regular expressions which match component 'Reference' fields of components that
# are to be excluded from the BOM.
excluded_references = [
    'TP[0-9]+',            # all test points
    '^\D{1,3}[5,7]\d+',    # Pages 5 and 7
    '^FID.+',              # Fiducials
    '^JP\d+',              # Jumpers
    '^H\d+'                # Mounting holes
    ]

More advanced BOM generators like KiBom can recognize board variant field which will let you generate separate BOMs for your motherboard and daughterboards.

Thanks
I somehow missed KiBom. I’ll have a look at it.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.