# KiCad BOM plugins (was KiCad BOM in Markdown)

**URL:** <https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368>\
**Category:** DIY STUFF\
**Created:** [July 3, 2020, 12:55am UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368 "2020-07-03T00:55:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![d42kn355](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/d42kn355/32/273_2.png) [@d42kn355](https://lookmumnocomputer.discourse.group/u/d42kn355)\
**Post date:** [July 3, 2020, 12:55am UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/1 "2020-07-03T00:55:08Z")

</div>

Just copy and paste what into what???

where does all that crazy text go?

where is the .py or whatever file?

im a noob… halp…

> [@Kosmo Sequential Switch](https://lookmumnocomputer.discourse.group/t/kosmo-sequential-switch/1177/12):
>
> Yeah, they provide a bunch of BOM scripts just about all of which are pretty useless, so I wrote my own. It writes a Markdown format file. # # Python script to generate a BOM from a KiCad generic netlist # # Sorted and Grouped Markdown BOM with advanced grouping # same as version from KiCad install but without footprints # """ @package Generate a Markdown BOM list. Components are sorted and grouped by value Fields are (if exist) Ref, Quantity, Value, Part, Description, Vend…

i just tried to generate a BOM from KiCAD and it was absolutely atrocious… if any of you have tried to do the same… you know as well as I do that i may as well just do it cell by cell lmao.

please. baby steps like im stupid… lol

and whats a markdown file… ?

---

<div class="post-metadata">

**Author:** ![Caustic](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/caustic/32/15588_2.png) [@Caustic](https://lookmumnocomputer.discourse.group/u/Caustic)\
**Post date:** [July 3, 2020, 1:49am UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/2 "2020-07-03T01:49:45Z")

</div>

I’ll wait for @analogoutput to explain, since this seems it uses a separate python environment maybe KiCad has it’s own environment?

---

<div class="post-metadata">

**Author:** ![analogoutput](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/analogoutput/32/29663_2.png) [@analogoutput](https://lookmumnocomputer.discourse.group/u/analogoutput)\
**Post date:** [July 3, 2020, 2:07am UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/3 "2020-07-03T02:07:00Z")

</div>

I wrote it up as a blog post:

> **[Mark down your BOM](https://analogoutputblog.wordpress.com/2020/07/03/mark-down-your-bom/)**
>
> KiCad’s pretty powerful and it’s my EDA of choice, but there are weaknesses. One of them is bill of materials (BOM) export. In KiCad’s schematic editor, Eeschema, you can click on…

  
Let me know what I left out or didn’t make clear.

---

<div class="post-metadata">

**Author:** ![analogoutput](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/analogoutput/32/29663_2.png) [@analogoutput](https://lookmumnocomputer.discourse.group/u/analogoutput)\
**Post date:** [July 3, 2020, 2:08am UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/4 "2020-07-03T02:08:07Z")

</div>

> [@d42kn355](#):
>
> im a noob

No you’re not

> [@d42kn355](#):
>
> baby steps like im stupid

No you’re not

---

<div class="post-metadata">

**Author:** ![Caustic](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/caustic/32/15588_2.png) [@Caustic](https://lookmumnocomputer.discourse.group/u/Caustic)\
**Post date:** [July 3, 2020, 2:42am UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/5 "2020-07-03T02:42:31Z")

</div>

Thanks @analogoutput! This looks nifty! Do you know if the windows KiCad bundles with a python environment? Windows (unfortunately) does not have a system python. Any idea if the linux version just uses the sytem level python? I didnt see you mentioning installing any modules etc, and i see some imports in the code that arnt stock.

![image](https://global.discourse-cdn.com/free1/uploads/lookmumnocomputer/original/2X/5/5a123842f863e9abc8091c612790a95711df55fa.png)

Of course, if these are “pre-compiled” python plugins thats a horse of a different color.

---

<div class="post-metadata">

**Author:** ![analogoutput](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/analogoutput/32/29663_2.png) [@analogoutput](https://lookmumnocomputer.discourse.group/u/analogoutput)\
**Post date:** [July 3, 2020, 2:48am UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/6 "2020-07-03T02:48:35Z")

</div>

As it says in the blog post, you have to put kicad\_netlist\_reader.py into the same directory as the BOM plugin.

I just assumed KiCad uses the system Python but maybe not. No idea about Windows. But the KiCad-supplied BOM scripts are Python, or at least some are, and if the same scripts are used in the Windows version then either it packages its own Python environment or it would require one be installed, I suppose.

---

<div class="post-metadata">

**Author:** ![Caustic](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/caustic/32/15588_2.png) [@Caustic](https://lookmumnocomputer.discourse.group/u/Caustic)\
**Post date:** [July 3, 2020, 2:52am UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/7 "2020-07-03T02:52:25Z")

</div>

I just know windows is going to be at fault. If this is pre-compiled, it would bundle all of the dependencies necessary. Alls im saying is if we got some windows users here (probably), they may have more trouble than what is covered in your blog post.

We will burn that bridge when we get there.

---

<div class="post-metadata">

**Author:** ![Farabide](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@Farabide](https://lookmumnocomputer.discourse.group/u/Farabide)\
**Post date:** [July 3, 2020, 2:57am UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/8 "2020-07-03T02:57:21Z")

</div>

This is not a problem I have encountered using online EDA with a chromebook or android device.  
Longing for the day my windows only software will run reliably on Linux so my last windows machine will die and I’ll get an average of 28 working hours a year back not having to “please wait while we update” (it’s close but not there yet)

---

<div class="post-metadata">

**Author:** ![analogoutput](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/analogoutput/32/29663_2.png) [@analogoutput](https://lookmumnocomputer.discourse.group/u/analogoutput)\
**Post date:** [July 3, 2020, 3:06am UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/9 "2020-07-03T03:06:43Z")

</div>

There’s this

> **[How to create a bill of materials (BOM)?](https://forum.kicad.info/t/how-to-create-a-bill-of-materials-bom/12346)**
>
> There are two options in KiCad to create a BOM. Either from the schematic or pcb side. Creating a BOM via pcb\_new is very simple but also limited in its capabilities (The pcb knows only about the reference, value and footprint assigned to a symbol.)...

---

<div class="post-metadata">

**Author:** ![feralbeagle](https://avatars.discourse-cdn.com/v4/letter/f/c6cbf5/32.png) [@feralbeagle](https://lookmumnocomputer.discourse.group/u/feralbeagle)\
**Post date:** [July 3, 2020, 5:05am UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/10 "2020-07-03T05:05:28Z")

</div>

OK, baby steps. If you are generating a BOM from the schematic, there is a menu item to generate a BOM. It should have some selections in it like this. ![image](https://global.discourse-cdn.com/free1/uploads/lookmumnocomputer/original/2X/e/e6616c42b354b3b7b1c57bddfeb488580a5a1645.png) After you select “Generate” it will make a new output file. For the highlighted selection in the image, it will generate a new file that has the same name as your project but it will not have an extension. Windows will not know what to do with it. Rename the file and add “.csv” to the end of the file name, be sure to include the “.”, then it will open in excel with all the columns correctly sorted.

---

<div class="post-metadata">

**Author:** ![analogoutput](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/analogoutput/32/29663_2.png) [@analogoutput](https://lookmumnocomputer.discourse.group/u/analogoutput)\
**Post date:** [July 3, 2020, 11:02am UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/11 "2020-07-03T11:02:33Z")

</div>

You can and should modify the command line at the bottom to include the extension. That change will persist, so you won’t have to do it every time.

---

<div class="post-metadata">

**Author:** ![feralbeagle](https://avatars.discourse-cdn.com/v4/letter/f/c6cbf5/32.png) [@feralbeagle](https://lookmumnocomputer.discourse.group/u/feralbeagle)\
**Post date:** [July 3, 2020, 5:42pm UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/12 "2020-07-03T17:42:06Z")

</div>

The change is persistent? Oh, thank you! I really thought it was not. This changes everything!

So baby steps. In the image where it says command line, for windows it should have  
python “C:\Program Files\KiCad\bin\scripting\plugins/bom\_csv\_grouped\_by\_value\_with\_fp.py” “%I” “%O”  
add .csv to the output like this:  
python “C:\Program Files\KiCad\bin\scripting\plugins/bom\_csv\_grouped\_by\_value\_with\_fp.py” “%I” “%O.csv”  
You can also add .html to the ones that say “html” in the description. Do not add .csv to the ones that have html in the description. Once you have these figured out and working, you can add new plugins.

---

<div class="post-metadata">

**Author:** ![feralbeagle](https://avatars.discourse-cdn.com/v4/letter/f/c6cbf5/32.png) [@feralbeagle](https://lookmumnocomputer.discourse.group/u/feralbeagle)\
**Post date:** [July 6, 2020, 6:24pm UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/13 "2020-07-06T18:24:54Z")

</div>

Is there a good tutorial about making KiCad plugins work? I see them in the directory, I find links to writing plug ins, but I do not know how to download, add, and use plug ins. I posted in the KiCad forum but no response yet. I need baby steps for this part to get started.

---

<div class="post-metadata">

**Author:** ![feralbeagle](https://avatars.discourse-cdn.com/v4/letter/f/c6cbf5/32.png) [@feralbeagle](https://lookmumnocomputer.discourse.group/u/feralbeagle)\
**Post date:** [July 7, 2020, 5:47am UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/14 "2020-07-07T05:47:35Z")

</div>

OK, it works! The person who wrote the KiCad Action Plugins posted on the KiCad list. Instructions for plugins are usually in the readme file. Here is a link to the instructions for the action plugins.

> **[openscopeproject/InteractiveHtmlBom](https://github.com/openscopeproject/InteractiveHtmlBom/wiki/Installation)**
>
> Interactive HTML BOM generation plugin for KiCad. Contribute to openscopeproject/InteractiveHtmlBom development by creating an account on GitHub.

Here are notes from my installation experience.

1. The new folder, ‘C:\Users[USERNAME]\AppData\Roaming\kicad\scripting\plugins’ has to be created. It does not install with KiCad. The KiCad folder ‘C:\Program Files\KiCad\share\kicad\scripting\plugins’ is not a good place because the folder may be overwritten by a KiCad update.
2. The folder depth can only be one deep. Adding the folder “Kicad\_action\_plugins” with the subdirectories in place to the new plugins folder does not work.
3. In Windows, you will be asked for permission to copy files to the new folder in `C:\Users\username\AppData\Roaming\kicad\scripting\plugins` Does this mean that the folder is still writable by KiCad and is there a way to test this? Everything seems to work!
4. New menu items appear in the Pcbnew menu Tools \> External Plugins.

---

<div class="post-metadata">

**Author:** ![juggle](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/juggle/32/6100_2.png) [@juggle](https://lookmumnocomputer.discourse.group/u/juggle)\
**Post date:** [October 14, 2020, 5:19am UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/15 "2020-10-14T05:19:03Z")

</div>

So been re-teaching myself kicad the past few days…and have a schematic far enough I’m looking to generate a BOM and build a board for it. I have to say KiCad has come a long way since I last tried it 5 years ago. It still infuriates me in some little ways…but I’m pretty sure I can get used to them.

I have a license for Eagle since I have Fusion360…but apparently as of v9 Eagle removed the CAM processor they had for generating inverted PDF’s which is rather important for the way I’m looking to make DIY boards. There are work arounds but they’re really clunky. The cleanest one is to export as inverted Gerbers. But then you need a 3rd party gerber viewer to print them…and if you want to put multiple boards on one piece of transparency it gets REALLY ugly.

With kicad I can just print to an inverted PDF and then open that in photoshop where I can then arrange as many as I want on one sheet for printing. Not idea but a lot easier and cleaner than the Eagle method.

Anyway…I’m trying @analogoutput’s markdown BOM generator…but getting an error:

```
Command error. Return code 1
Error messages:
Traceback (most recent call last):
  File "C:\Users\jhite\AppData\Roaming\kicad\scripting\plugins/bom_group_md.py.py", line 88, in <module>
    md = md.replace('<!--SOURCE-->', r.group(1))
AttributeError: 'NoneType' object has no attribute 'group'

```

Note I’ve tried putting the script in c:\program files\kicad\scripting\plugins as well and it gives the same error. The kicad\_netlist\_reader.py file is there in both locations…but it seems like either it’s not working or it’s not generating the expected output.

I know enough python to muddle my way around…it looks like the problem is with ‘r’ which is created on line 87 and appears to be trying to load a .sch file. But…I’m not sure what re is…I see it’s imported so I assume it’s a Python library (I’m guessing one for reading files?) and I’m guessing the problem is it’s trying to open the .sch file for my project and not finding it…maybe because of windows vs. @analogoutput being on linux?

Any input on this AO? Or anyone else use the script on Windows?

I’m going back to routing for now and will mess with this more tomorrow.

---

<div class="post-metadata">

**Author:** ![juggle](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/juggle/32/6100_2.png) [@juggle](https://lookmumnocomputer.discourse.group/u/juggle)\
**Post date:** [October 14, 2020, 5:31am UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/16 "2020-10-14T05:31:36Z")

</div>

Ok…didn’t fee like going back to the ratsnest just yet.

So I see that re is actually the Python regex library. Makes sense.

And that line is actually searching in ‘s’ which according to the line above comes from net which is the output from the kicad\_netlist\_reader

So…it looks like it probably is a problem with the netlist\_reader after all. But I’m too tired to dig any deeper than that tonight 😴

---

<div class="post-metadata">

**Author:** ![eric](https://avatars.discourse-cdn.com/v4/letter/e/898d66/32.png) [@eric](https://lookmumnocomputer.discourse.group/u/eric)\
**Post date:** [October 14, 2020, 6:17am UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/17 "2020-10-14T06:17:49Z")

</div>

> [@juggle](#):
>
> With kicad I can just print to an inverted PDF and then open that in photoshop where I can then arrange as many as I want on one sheet for printing.

If you have the PS step anyway in your pipeline, it really isn’t that much work to flip a layer after importing the pdf…  
Not that I recommend eagle, the free version has so many limitations it is close to useless.

> [@juggle](#):
>
> It [Kicad] still infuriates me in some little ways…

Me too 🙂  
The “high-level” workflow is still very 90’s, where you have to export/import your netlist all the time…

---

<div class="post-metadata">

**Author:** ![fredrik](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/fredrik/32/682_2.png) [@fredrik](https://lookmumnocomputer.discourse.group/u/fredrik)\
**Post date:** [October 14, 2020, 8:54am UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/18 "2020-10-14T08:54:35Z")

</div>

> [@juggle](#):
>
> ```auto
> Traceback (most recent call last):
> File "C:\Users\jhite\AppData\Roaming\kicad\scripting\plugins/bom_group_md.py.py", line 88, in <module>
> md = md.replace('<!--SOURCE-->', r.group(1))
> AttributeError: 'NoneType' object has no attribute 'group'
> 
> ```

This means that `r` is None, instead of an `re` match object, which means the regexp didn’t match (and someone didn’t add enough error handling 😀).

---

<div class="post-metadata">

**Author:** ![analogoutput](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/analogoutput/32/29663_2.png) [@analogoutput](https://lookmumnocomputer.discourse.group/u/analogoutput)\
**Post date:** [October 14, 2020, 12:13pm UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/19 "2020-10-14T12:13:16Z")

</div>

It’s looking in the string s for a match to the regular expression `^.*/(.*)\.sch` and not finding it.

s is the result of a call to `net.getSource()` from the kicad\_netlist\_reader module. It’s supposed to return the path to the schematic file.

I didn’t write bom\_group\_md.py from scratch, I adapted it from another script distributed with KiCad, and that part of the code is unchanged from the other script, so if it doesn’t work, I would think other BOM scripts also would fail the same way. If not maybe you could look into the other scripts and see if they do something different.

You could try printing s to see what `net.getSource()` is returning.

Alternatively you could just comment out lines 87 and 88 and have `<!--SOURCE-->` appear in your BOM where the file name is supposed to be.

---

<div class="post-metadata">

**Author:** ![fredrik](https://yyz2.discourse-cdn.com/free1/user_avatar/lookmumnocomputer.discourse.group/fredrik/32/682_2.png) [@fredrik](https://lookmumnocomputer.discourse.group/u/fredrik)\
**Post date:** [October 14, 2020, 12:32pm UTC](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368/20 "2020-10-14T12:32:14Z")

</div>

> [@analogoutput](#):
>
> the regular expression `^.*/(.*)\.sch`

Looks like juggle is using Windows. Is the filename normalized at that point?

(fwiw, helpers like `os.path.basename` and `os.path.splitext` are more robust than regexps.)

[Next page](https://lookmumnocomputer.discourse.group/t/kicad-bom-plugins-was-kicad-bom-in-markdown/1368.md?page=2)
