BOM Script: a way to exclude part from BOM by custom field

Regarding these files: File1: https://gitlab.com/kicad/code/kicad/-/blob/master/eeschema/plugins/python_scripts/kicad_netlist_reader.py

and File2 (+line of interest): https://gitlab.com/kicad/code/kicad/-/blob/master/eeschema/plugins/python_scripts/bom_csv_grouped_by_value.py#L84

Also, regarding this thread: To exclude Virtual footprints from BOM [SOLVED]


What do I want: I am trying to make custom csv bom, based on File2. I want to exclude DNP (Do Not Populate) components from BOM, if component has “DNP” field and this field is not empty. All symbols on schematics have “DNP” field, and in case this field contains a value, BOM script should ignore it.

Question #1 is: Can this be done in other easy way instead of modifying File1? I mean File1 is part of kicad’s installation, why should I modify that? Nobody should temper files, created by software installer, I think. These files will probably get overwritten next time software update is available, thus causing my modifications to be lost.

Explanation:File1 is hardcoded to omit components, having field "Installed" = "NU", and I want to change this to "DNP" != "". So, I go to https://gitlab.com/kicad/code/kicad/-/blob/master/eeschema/plugins/python_scripts/kicad_netlist_reader.py#L627 and append these lines there:

if c.getField( "DNP" ) != '':
exclude = True

Now my custom BOM script only prints what I needed, but accomplished this by modifying kicad installation file…


Just a note, that @qu1ck 's iBOM https://github.com/openscopeproject/InteractiveHtmlBom plugin works the same way, it has a dedicated setting for that:

It successfully omits components, with DNP field not empty from html BOM. I want to do exactly the same, but from eeschema BOM plugin.

Question #2: Maybe File1 in kicad master should be improved to be more flexible? Is this worth filling an wishlist issue in gitlab, or is it intended for users to modify File1?**

Question #3: Can this “configuration” section lines 26 https://gitlab.com/kicad/code/kicad/-/blob/master/eeschema/plugins/python_scripts/kicad_netlist_reader.py#L26)) to 71 be changed (overridden) from outside code? (My python knowledge is zero)

To be more clearer about q#3: iBom plugin has these blacklist configurable, it would be perfect if the same configuration options would be available from python code):

(Mentioning iBOM here a lot because it is the most valuable addition to kicad as I know…)

I have copied kicad_netlist_reader.py and bom_scv_grouped_by_value.py to my working directory and modified them there (also renamed that bom_csv… file to something like my_bom.py). Then in Tools-Generate BOM window I added my_bom.py to list of BOM plugins. KiCad remembers that it is my default so after selecting Generate BOM I have only to click [Generate] key.
That way my files are not overwritten when installing new KiCad versions, but if programmers will improve something in those files I will not get it until I will compare my files with current ones. Using new files will probably need once more to understand what and how I should modify there something. But until my files work good for me what for I should look for improvements.

1 Like

Ok, created MR for this: https://gitlab.com/kicad/code/kicad/-/merge_requests/901

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