Interactive Html Bom Plugin for KiCad

Take a look at the KLC check script: https://github.com/KiCad/kicad-library-utils/blob/6511674aab078c053b20e1eb7790830513da11dc/pcb/rules/F7_3.py#L12

There we use [‘1’, ‘A’, ‘A1’, ‘P1’, ‘PAD1’]

I think a better method would be to analyze all pad numbers of a part. Example: sort alphanumerically and use the lowest entry. (Or at least this can be done if none of the predefined options is found)

2 Likes

wow, thank you so much for this! I saw it on twitter and hackaday and bookmarked it. It is so awesome!
I’m just working with a Chinese assembly house and have asked them if they want to use this instead of screenshots - I think it’s going to be so much easier.

3 Likes

Thank you for providing this utility. I downloaded and used it immediately this morning with most satisfactory results. The interaction with the layout to highlight components is a great idea. I was also able to simply save the BOM as a text file, import it into a spreadsheet and remove columns that are irrelevant to stores/purchasing (i.e. footprints); just what I needed to find originally. As a side note to any users: simply having generic values in your Bill of Materials (like 22uF) is not very helpful to purchasing or manufacturing, they need unique company or manufacturer codes (sorry if this doesn’t really belong here).

In upcoming version 2 of the plugin there will be an option to backfill BOM with extra fields pulled from netlist or xml file generated from eeschema. You can then put manufacturer part # or whatever else you want to help you identify parts in additional fields on components in schematic and that will appear in bom.

1 Like

Excellent, that sounds just the ticket. Thanks marra!

@qu1ck, interesting, just some points to help your road map. This option to fill with BOM / netlist option is nice, but:

  1. The python script should try and pass or warning if don’t found any netlist / xml BOM;
  2. May be better use the BOM instead the the netlist, because now there is an option to synchronize Eeschema->PcbNew without netlist file creation. Even, in the developer “forum” (launchpad) there is some discussion to add new information at the netlist / Eeschema / PcbNew files, what should create some problems at KiCad 6, but the xml will be keep with changes;
  3. The interactive HTML plugin will have to check if the XML file is up-to-date with the Pcb (maybe checking with all the references and values are equal to the Pcb);
  4. If you decide to XML file, you can use with routine https://github.com/xesscorp/KiCost/blob/master/kicost/edas/eda_kicad.py, https://github.com/xesscorp/KiCost/blob/master/kicost/edas/tools.py which already ready manf# (and it’s synonyms) code and could help us to integrate the tools around some standardization.
3 Likes

Thanks for pointers

  1. It won’t look for the file, you have to choose it in file dialog or pass on command line.
  2. You will have option to use either netlist or xml. In the future maybe reading schematic files directly will be implemented too.
  3. Yes, I already have some checks. It will show a warning if components don’t match.
  4. Wow, that code has more comments than code. I don’t think I will need much of that logic, you will just choose field name(s) in GUI or pass as command line arguments in my case.

(2) Better wait for the eeschema python package (to ready directly the .sch file), already in discussion but not implemented, this will leave your code not dependent of file formats.

(4) Yes, a lot of comments due some refacture and bug fix to read since KiCad v4 and interpretation of the fields by different users
behaviour (e.g. manf#, mpn, p# are translated to manf#; digikey#, digikey-p#, digikey_p# as digikey# … being better to group in this specif made tool).

To people following development and who are somewhat power users: I could use help with testing latest revision.

I just pushed a big update to github. You can call it a v2 release candidate but I haven’t done sufficient testing to officially tag it yet.
Please try it out if you have time to tinker with potentially unstable version and report any bugs to me.
But there are a bunch of goodies:

Things that are not implemented yet: saving settings in dialog and loading netlist file (only xml file works for now).

Update: netlist parser implemented.
So pretty much everything should work now, except that you’ll have to enter all parameters every time you invoke the plugin. That’s what save settings button is for, which I’ll get to in a bit.

3 Likes

Hi,

I’m trying to use your plugin, but all the times when open pcbnew it gives segfault.

Did clone github to a folder and then created the folowing folders:
.config/kicad/scripting/plugins/
or
.config/kicadnightly/scripting/plugins/

Inside did try copy the folder and make symbolic link, every time is segfault.

My system is linux mint 19 xfce and have release and nightly installed at same time.

It’s a known issue with latest debian and ubuntu based distributions that don’t provide wxpython built with wxwidgets linked with gtk2. Sorry, for now you have to use plugin from command line. KiCad 5.1 is supposed to solve this problem.

Congratulations @qu1ck, this achieve some of the features requested.
Some tips:

  1. It will be nice auto fill the Netlist of xml file with the xml file name;
  2. Could be nice save the setting of your GUIDE (wxPython have support to do, a example could be found at https://github.com/xesscorp/KiCost/blob/master/kicost/kicost_gui.py functions save_properties() and restore_properties();
  3. I could assign a different XML (for other project) to my iBOM. Could be smart and user responsive to check with the XML/Netlist file have the same designators (R*, C*, …) that the PCB and warning the user;
  4. The ‘dark them’ appear to be always checked in the output file, not mattering checked or not in the GUI. (could it be because the cookie of a file that I already have generated?);
  5. Same to the ‘highlight first pin’.

Thanks for feedback, let me reply on each point:

  1. I think it could be done. Search for .xml and .net files in same directory as pcb file and pick the most recent one.
  2. Yes, I provisioned “save settings” button for that. I took a look at your code, looks like wx.Config writes to registry on win, I will probably use wx.FileConfig since registry is evil™.
  3. Also planned
  4. and 5. You are right, settings are cached in browser (but in LocalStorage, not in cookies). Settings in config dialog are defaults which will be relevant for new browser session.

About 2, YES, on Windows HK_USER\Software\your_name_def\. In Linux it saves a file in $HOME\your_name_def’. On Mac, I didn’t read about / had experienced.

One idea could be just generate a ibom_config.inf file in the project folder to be (try) read at the second time that iBOM is started.

About the feedback, as I friend mine, also developer, told me once: ‘the easier it is or less clicks for the user, more work for the programmer’ :slight_smile:
I hope, in some way my code / feedback can help you.

  1. and 3. are implemented.

Now just need to save settings. Not sure if they should be global or per project. On one hand I don’t like adding junk to project directory, on the other hand having settings be global can be tricky.

Thank you for great work. Can you add support of UTF8 filepath?

Traceback (most recent call last):
  File "InteractiveHtmlBom/InteractiveHtmlBom/generate_interactive_bom.py", line 655, in <module>
    board = pcbnew.LoadBoard(os.path.abspath(args.file))
  File "/usr/local/lib/python2.7/dist-packages/pcbnew.py", line 7409, in LoadBoard
    return _pcbnew.LoadBoard(*args)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 60: ordinal not in range(128)

I fixed one minor issue related to utf8 files but on Linux there seems to be some bug that prevents pcbnew to read files with non ascii names. Here is simple repro:

quick@debian:~$ cat t.py
# encoding: utf8
import pcbnew

print pcbnew.LoadBoard(u'1ა.kicad_pcb')
quick@debian:~$ python t.py
Traceback (most recent call last):
  File "t.py", line 4, in <module>
    print pcbnew.LoadBoard(u'1ა.kicad_pcb')
  File "/usr/local/lib/python2.7/dist-packages/pcbnew.py", line 8542, in LoadBoard
    return _pcbnew.LoadBoard(*args)
IOError: Unable to open filename "1ა.kicad_pcb" for reading

Maybe @pointhi can help? I can’t get pcbnew.LoadBoard() to accept unicode filename on linux.

Update: nevermind, I figured out the issue. wxGTK does some shenanigans with file name encodings on wxApp::Init(). Workaround is to create a wx.App() even if you don’t need any windows. Unicode file names issue should be fixed in latest from repo.

v2.0 is out!

This is a big update with much requested functionality finally added.
Most important change is the new configuration dialog and ability to pull extra data from netlist or xml file.

With config dialog you can

  • Add extra columns to BOM with arbitrary data like manufacturer part number
  • Configure HTML defaults
  • Change bom destination directory
  • Mark parts as DNP (do not populate) to skip them in BOM
  • Add explicit part blacklist
  • Configure BOM table default sort order

I’ve already shared a picture of the dialog above, it hasn’t changed much.

Other fixes include:

  • Correctly parse boards with components that have duplicate references. Now panelized boards work properly.
  • Fix for boards with utf8 file names
  • Fix dark theme bug with background of bom table in ‘bom only’ mode
  • Fix plugin clashing with some other action plugins

Also there is a new copy to clipboard button to help you easily copy data into excel or other spreadsheet software.

I’ve moved the instructions from readme to project wiki which is easier to update.

6 Likes

You’ve done amazing work with this. I think I need to upgrade my microwave to play Doom 3D so we can work on getting this plugin ported over. :wink: (@others if you don’t get the joke, read the FAQ.)

1 Like

I am new user of KiCad and am still getting to grips with using it and it’s quirks. When I searched for a plugin to make a BOM, this is the first thing that came up. I followed the instructions and it just works! Perfectly!

Thank you very, very much! This generates the nicest BOM ever and potential completely replaces assembly drawings!

1 Like