KiCad BOM Wizard Plugin with customisable output (Can make HTML and CSV BOM)

Hi @Miceuz just noticed that my kicad_bom_wizard package didn’t include the actual javascript. Sorry I’ve pushed an update which should solve this issue.

On a different note, I’ve noticed that you aren running an out of data version of node and npm. the current version is

Ron@HDE_VB:~$ node -v
v4.2.6
Ron@HDE_VB:~$ npm -v
2.14.12

Could you install the latest version. You can do it by using the prebuild binary package. Here’s a link on how to do it via stackoverflow

Here’s that same instruction but update to for today’s current version.

for 64bit linux

# this will remove old version from your system
sudo apt-get remove nodejs node npm

cd ~/

# download the latest version as of 08 feb 2016
wget https://nodejs.org/dist/v4.2.6/node-v4.2.6-linux-x64.tar.xz 

# extract the tar file
tar xf node-v4.2.6-linux-x64.tar.xz

# move it to the correct location in your system
sudo cp -rp node-v4.2.6-linux-x64 /usr/local/

# add a symbolic link so node. this will make it easy to update node in the future
sudo ln -s /usr/local/node-v4.2.6-linux-x64/ /usr/local/node

# now we need to add /usr/local/node/bin to our system path. assuming ubuntu without zsh
printf "\nexport PATH=/usr/local/node/bin:\$PATH\n" >> ~/.profile

# You will need to logout and log back in for the system path to start using /usr/local/node/bin
# check if you the new path in your system
echo $PATH

# check node and npm version
node -v
npm -v

-ROn

Hi,
I really like the plug in but I still have some questions:

  1. Where can I add/edit the names for the designators. Because I have some custom designators that are of course not supported. (edit: found it in the template.conf file!)
  2. This is a more general question but what is the right command to safe the generated bom file in a folder located in the project folder. i.e. generate BOM.html and safe it into /projectfolder/BOM with “%O.html” I can just safe the file into the root directory of the project.
  3. Some of my designs have SMD pads that are in the schematic but what I don’t need them on the BOM because they are integrated on the board/design. Is there a way to hide specific parts in the BOM?

Best Regards, Suckiden

to 3) footprint attribute property should be set to ‘virtual’ I think.
usually it’s set to ‘normal’ = through hole (doesn’t appear in position file) and the other one is ‘normal+insert’ = smd (appears in position file)

Where can I add/edit the names for the designators. Because I have some custom designators that are of course not supported. (edit: found it in the template.conf file!)

Awesome. But Just in case anyone else wanted to know.
The file that you will need to edit in order to add your own designators name is the template file Template/HTML/template.conf

The plugin will generate class names for every unique designator that its finds and the format of the name is group_{ designator} where {designator} is the component prefix. For example, capacitor designator is C. So the class name will be group_C. note, the designator is case sensitive, so you will need to make sure that it matches that of your projects.

To add a new designator to the HTML template you will need add the CSS code that will set the group_ class content to the Name you want.

To see an example, you can go to line 85 in Template/HTML/template.conf which has the code for the capacitor.

.group_C:after{
    content:"Capacitors";
}

I would recommend that you modify a copy of the HTML template just in case you are planning on updating the plugin.


This is a more general question but what is the right command to safe the generated bom file in a folder located in the project folder. i.e. generate BOM.html and safe it into /projectfolder/BOM with “%O.html” I can just safe the file into the root directory of the project.

Good question. :smiley:
So I’ve been looking at the KiCad source code and it turns out that the KiCad pluging manager has some extra parameter that we can pass to achieve exactly what you want. on teh command line we can use %P to get the project root path and %B to get the project name.

So for you where you want a BOM directory, the command would look like this.

kicad_bom_wizard "%I" "%P/BOM/%B.html"

Just in case anyone else wanted to know, the KiCad source file I found the parameter is netlist_exporter.cpp line 53

Here’s the code snip:

// Expand format symbols in the command line:
// %B => base filename of selected output file, minus path and extension.
// %P => project directory name, without trailing '/' or '\'.
// %I => full filename of the input file (the intermediate net file).
// %O => complete filename and path (but without extension) of the user chosen output file.
2 Likes

@Joan_Sparky where exactly can I find this option. In the schematic editor or in the PCBnew editor? I looked into both but couldn’t find this option.

@Opticalworm thanks you for your reply, I am already very happy with the script :slight_smile: the only feature I would like to have in the future is an assist that helps you when you manually place components. There is already a pretty interesting script out there that highlights all components of a kind and creates different images http://hackaday.com/2016/02/09/stickerbom-for-kicad/. I know that your script and this one is pretty different, but a combination of both of them would be very handy.

Don’t hit me for this suggestion but I am just thinking out loud:
What if you could generate a HTML side pretty much like your BOM side but separated into two columns, on the left is the BOM list and on the right are the corresponding images to your selection in the BOM. So if I select the row with the 100nF capacitors on the left the correct image where all capacitors on the board are highlighted is showed on the right.

let me know what you think about this!

Suckiden

1 Like

That’s a footprint properties element… so in the footprint editor - in your nomenclature ‘PCBnew editor’.

@suckiden
Thanks for that link, looks neat. Similar to the other documentation for assembly pdf generator someone else posted here some time ago.

from here:

I am having trouble running the script, I instaled on a fresh VM with Ubuntu 14.04, latest node.js v4.4.1 and installed kicad_bom_wizard via npm.

This is the bom generated from kicad, in cade you need: https://drive.google.com/open?id=0B1B3k6IxdZ2dVXhnY1BqOThKa00

I allways tet this erro, please heler:
$ kicad_bom_wizard Cvt4.xml Cvt4-BOMw.csv CSV
KiCad_BOM_Wizard Rev: 0.0.2
reading KiCad XML file [ Cvt4.xml ]
Reading Template [ /usr/local/lib/node_modules/kicad_bom_wizard/Template/CSV ]
Generating BOM [ Cvt4-BOMw.csv ]
/usr/local/lib/node_modules/kicad_bom_wizard/KiCad_BOM_Wizard.js:369
Template = Template.replace(//g, UserProjectNetData.export.design[0].sheet[0].title_block[0].title)
^

TypeError: Cannot read property ‘0’ of undefined
at GenerateBOM (/usr/local/lib/node_modules/kicad_bom_wizard/KiCad_BOM_Wizard.js:369:91)
at Task (/usr/local/lib/node_modules/kicad_bom_wizard/KiCad_BOM_Wizard.js:600:7)
at /usr/local/lib/node_modules/kicad_bom_wizard/KiCad_BOM_Wizard.js:512:7
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)

Hi Alainm, Sorry for the delay it was bank holiday here in the UK.

The google drive link you posted is asking me to request access. Would you be able to post an open link to the file or possible paste the xml file in here.

  • Ron

That’s really cool and useful and even puts my custom tags in there (I put the part number and a distributor part code on everything in the schematic).

Only thing is, I can’t get eeschema to run it, however if I paste the command line it works fine. This is on OSX, I used the npm installer to install it.

Run command:
kicad_bom_wizard “/Users/rols/KiCad/Remote/remote.xml” “/Users/rols/KiCad/Remote/remote.html”

Command error. Return code -1

Error messages:
execvp(kicad_bom_wizard, /Users/rols/KiCad/Remote/remote.xml, /Users/rols/KiCad/Remote/remote.html) failed with error 2!

but from the command line

$ kicad_bom_wizard “/Users/rols/KiCad/Remote/remote.xml” “/Users/rols/KiCad/Remote/remote.html”
KiCad_BOM_Wizard Rev: 0.0.2
reading KiCad XML file [ /Users/rols/KiCad/Remote/remote.xml ]
Reading Template [ /usr/local/lib/node_modules/kicad_bom_wizard/Template/HTML ]
Generating BOM [ /Users/rols/KiCad/Remote/remote.html ]
BOM created

I tried explicit paths and a few other things but started to make more mess than progress. Any ideas?

Hi @rolandking,

Unfortunetly, KiCad bash shell that it used don’t bring up your system path variable so it don’t know where to find kicad_bom_wizard or where nodejs is at. That is actually the same problem that @Margaret_Johnson had on her computer on this post above

So if you want to get it to work in kicad, you will need to find the path location for both nodejs and kicad_bom_wizard and type them into the bill of material command line:.

Your might look like this,
/usr/local/bin/node "**PATH_TO_PLUGIN**/KiCad_BOM_Wizard.js" "%I" "/Users/rols/KiCad/Remote/remote.html"

The %I should give the plugin the full path to the current project xml.

Let me know if that helps.

  • Ron

Perfect

/usr/local/bin/node /usr/local/bin/kicad_bom_wizard "%I" "%O.html"

does the job for me. And it’s been very useful too, I found a part I hadn’t annotated properly on the schematic and it proved to be one I nearly forgot to order, having them grouped like this is wonderful. Thanks for the plugin.

@rolandking Great to hear it :smiley:

Hi, thanks for your great work about the KICAD_BOM_WIZARD!

I want to report 2 bugs about the wizard.

BUG1, in HMS_1.htm, the values of C49 and C51 are “0.1u” and footprints “C0805”, but they are grouped with all the capacitors “0.1u” / “C0603”;

BUG2, when I try to fill the field “ORC” of C49 and C51 as “C0805xxx” expecting they could be seperated from “0.1u” / “C0603” group, the “0.1u” / “C0603” group suddenly EXPLODES! see MHS_2.htm :slight_smile:

Maybe there is some trouble of the network storage from baidu.com, the .xml and .htm files my posted not work properly yet ~

Hi @Samuel I assume you posted this message before my replying to your question on my site comment section. The Xml files worked quite well, it did take me a while to find the download link but wasn’t too bad. I’ve update the Plugin to fix the bugs you reported so if you don’t mind, could you check that it works for you.

For anyone following allong, the plugin wasn’t grouping similar components when it has detected one to be sightly different.This had the effect of creating a new row for every offending component.

-Ron

#Update 0.0.6
Hello Everyone, on this update, I’ve fixed a few bugs and added support for outputting the components footprint.

#Changes

  • Fixed the bug that was causing certain components to not group.
  • The plugin will now check the components footprint before grouping them
  • Added the footprint <!--ROW_PART_FOOTPRINT--> and <!--HEADER_CLASS_FOOTPRINT_TAG--> tags.
  • I’ve update the HTML template to show the footprint column and adjusted the columns width.

#Github repository and NPM register


2 Likes

Yes! 0.0.6 works very well! Thank you!

HI.

Very good work, congrats!!!
Please let me know, how can I change the order of columns, delete the footprint header and increase and others like type or observations ?

Thanks in advance

*** Adding some info… I got what I need doing mannually. I generated a CSV file, but I have changed the extension to TXT, then when a open with a excel the txt file, I got it more organized in cells

Hi @Claudio_Cardoso good see others wanting to customise the template.

Funny thing, I never though to check what would happen if I re-arranged the column. Unfortunately this is a bug. It should be possible to rearrange and remove most of the columns. In this case the header code ignored the order defined in the template file.

No problem, I’ve pushed an update which fixes this issue and should hopefully allow us to change the order or even remove columns.

###Instructions
this is what you would need to do to make your own custom template.

You will need to make a copy of the HTML template folder located in KiCad_BOM_Wizard/template/HTML and rename to anything you want. Say MyHTML
This should hopefully give you the option to use the original template should anything go wrong.

When you call the template make sure that you specify you own template folder like this.
assuming that you’ve placed myHTML in the plugin template.

node KiCad_BOM_Wizard.js “Test/Meter.xml” “Test/Meter.html” “Template/MyHTML”

###Editing
To edit the order or remove columns you will need to edit the row.conf file.
it should look like this;
`

`

You just need to either rearrange or remove the line which defines the column you want to change it startd with <div class='column'.....

This is what it would look like if you removed the footprint column and swapped the order of QTY and REF.
`

`

To edit the style you will need to know a bit of html and css. To edit the style, you will need to edit template.conf. line 33 has the css style for the column and header default width.
line 40 set the quantity column width.
It looks like this:
.column, .Head{ float: left; width: 135px; height: auto; text-align: center; margin: 10px; } .HeadQtyTag{ width: 20px; }

2 Likes

Thanks for answering man !

Yes, I have been editing somethings in those files before you wrote, and that motivated to write to you.

The 0.0.7 version works great. I will continue testing, thanks