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

Hello everyone,

I’m getting ready to add more features to the plugin and I just wanted to check if there’s was anything that anyone had in mind that might make it a little easier or more useful?

So far I’m planning on the following:

  • contribute to the KiCad project to add better support for NodeJs based plugins
  • option to extract BOM info directly from KiCad project files (about %70 complete)
  • split the project parser to a separate modules so that others can use it on their own NodeJs projects
  • Add UI for creating BOM templates
  • Add PDF support
2 Likes

OK. Not having much luck here. Installed according to the docs and found that i had to install xml2js. Now seeing this error when running manually:

C:\Elektronik\KiCad_BOM_Wizard-master>node “C:\Elektronik\KiCad_BOM_Wizard-master/KiCad_BOM_Wizard.js” “C:\Users\dalton\Filr\Mina filer\Hem\Kicad\HPDisk2\hpdisk2.xml” “C:\hpdisk2.csv” “C:\Elektronik\KiCad_BOM_Wizard-master/Template/CSV”
KiCad_BOM_Wizard Rev: 0.0.8
reading KiCad XML file [ C:\Users\dalton\Filr\Mina filer\Hem\Kicad\HPDisk2\hpdisk2.xml ]
Reading Template [ C:\Elektronik\KiCad_BOM_Wizard-master/Template/CSV ]
Generating BOM [ C:\hpdisk2.csv ]
C:\Elektronik\KiCad_BOM_Wizard-master\KiCad_BOM_Wizard.js:318
value.field.forEach(function (value) {
^

TypeError: Cannot read property ‘forEach’ of undefined
at C:\Elektronik\KiCad_BOM_Wizard-master\KiCad_BOM_Wizard.js:318:20

I’m surprised that you had to install xml2js. It looks like you’ve downloaded the project directly from git. If this is the case, then unfortunately you do have to run npm install in the project directory.

That said, you are better of installing the project via npm so that its handle installing any depdencies. For example, npm install -g --production kicad_bom_wizard.

With regard to the TypeError, would you be able to share your xml file for me to test?

  • Ron

I am trying to use your BOM Plugin on a Win10 system and am having trouble.

I installed nodejs and ran “npm install -g --production kicad_bom_wizard”

I am using command line: node “C:\Users\Ron\Util\KiCad_BOM_Wizard-master\KiCad_BOM_Wizard.js” “%I” “%O.html”

Here is what I get:

Run command:
node “C:/Users/Ron/Util/KiCad_BOM_Wizard-master/KiCad_BOM_Wizard.js” “C:/Users/Ron/Documents/Designs/100-0036C/100-0036C.xml” “C:/Users/Ron/Documents/Designs/100-0036C/100-0036C.html”

Command error. Return code 1

Info messages:
KiCad_BOM_Wizard Rev: 0.0.8

Error messages:
module.js:471
throw err;
^

Error: Cannot find module ‘xml2js’
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at ReadXmlFile (C:\Users\Ron\Util\KiCad_BOM_Wizard-master\KiCad_BOM_Wizard.js:433:16)
at Task (C:\Users\Ron\Util\KiCad_BOM_Wizard-master\KiCad_BOM_Wizard.js:608:7)
at Object. (C:\Users\Ron\Util\KiCad_BOM_Wizard-master\KiCad_BOM_Wizard.js:132:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions…js (module.js:579:10)
at Module.load (module.js:487:32)

Thanks for your help, Ron

I have similar problem like RonTon. I run KiCad also under Wndows10 with a command line:

node “C:\KiCad_BOM_Wizard-master\KiCad_BOM_Wizard.js” “%I” “%O.html”

and this is what I get:

Run command:
node “C:/KiCad_BOM_Wizard-master/KiCad_BOM_Wizard.js” “C:/kicad-source-mirror-master/demos/complex_hierarchy/complex_hierarchy.xml” “C:/kicad-source-mirror-master/demos/complex_hierarchy/complex_hierarchy.html”

Command error. Return code 1

Info messages:
KiCad_BOM_Wizard Rev: 0.0.8

Error messages:
module.js:471
throw err;
^

Error: Cannot find module ‘xml2js’
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at ReadXmlFile (C:\KiCad_BOM_Wizard-master\KiCad_BOM_Wizard.js:433:16)
at Task (C:\KiCad_BOM_Wizard-master\KiCad_BOM_Wizard.js:608:7)
at Object. (C:\KiCad_BOM_Wizard-master\KiCad_BOM_Wizard.js:132:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions…js (module.js:579:10)
at Module.load (module.js:487:32)

Best Regards!

I have now manged to do it. After installing the node trough npm:

C:\Users\pok>npm install -g --production kicad_bom_wizard
C:\Users\pok\AppData\Roaming\npm\kicad_bom_wizard -> C:\Users\pok\AppData\Roaming\npm\node_modules\kicad_bom_wizard\KiCad_BOM_Wizard.js
C:\Users\pok\AppData\Roaming\npm
-- kicad_bom_wizard@0.0.8 – xml2js@0.4.17
±- sax@1.2.1
-- xmlbuilder@4.2.1 – lodash@4.17.2

i used the path where npm installed the node:

C:\Users\pok\AppData\Roaming\npm\node_modules\kicad_bom_wizard\KiCad_BOM_Wizard.js

and now the command line in EEschema BOM menu looks like this for html:

node “C:\Users\pok\AppData\Roaming\npm\node_modules\kicad_bom_wizard\KiCad_BOM_Wizard.js” “%I” “%O.html”

and for csv:

node “C:\Users\pok\AppData\Roaming\npm\node_modules\kicad_bom_wizard\KiCad_BOM_Wizard.js” “%I” “%O.csv” “C:\Users\pok\AppData\Roaming\npm\node_modules\kicad_bom_wizard\Template\CSV”

Though I am not sure, I suppose the problem was that before I loaded the wizard from the folder where it was downloaded initially, and not from the folder where it was installed by the npm.

I hope that helps and thank you for the great work you have done!

I took the easy way out… opened up the XML-file in Excel and sanitised it there :slight_smile:

Hi Ron,
I’m new kid in the block when it come to using Ki_Cad, I just finished the project that I’m working on and I found out that creating the BOM is not easy. I might be guilty of creating some of the issue that I’m facing since each component has the following fields:

Reference
Value
Footprint
Datasheet
Manufacturer
Part Number
Voltage
Current
Power (Watts)
Tolerance
Operating Temperature

I’m using Window operating system. I followed the instruction you posted on Jan 16, i watched the 24 min video and i did exactly what you instructed

and I’m getting the following error:

Can’t open file C:\ProgramFiles|KiCad\share\KiCad\demos\complex_hierarchy.xml (error 0: the operation completed successfully.)

I’m kind of stuck, anything you can do to help me generate the BOM will be greatly appreciated.
Also I wanted to thank you for the fine work you have done

Best regards

Saad (ST2)

Hi Ron,
I got a better result after few attempts but I’m still getting the error, below is the BOM error report, hope this can shed light on this issue

Run command:
node “C:/My_Circuit_KICAD/KiCad_BOM_Wizard-master/KiCad_BOM_Wizard.js” “C:/My_Circuit_KICAD/GettingToBlinky/GTB.xml” “C:/My_Circuit_KICAD/GettingToBlinky/GTB.csv” “C:/My_Circuit_KICAD/KiCad_BOM_Wizard-master/Template/CSV”

Command error. Return code 1

Info messages:
KiCad_BOM_Wizard Rev: 0.0.8

Error messages:
module.js:471
throw err;
^

Error: Cannot find module ‘xml2js’
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at ReadXmlFile (C:\My_Circuit_KICAD\KiCad_BOM_Wizard-master\KiCad_BOM_Wizard.js:433:16)
at Task (C:\My_Circuit_KICAD\KiCad_BOM_Wizard-master\KiCad_BOM_Wizard.js:608:7)
at Object. (C:\My_Circuit_KICAD\KiCad_BOM_Wizard-master\KiCad_BOM_Wizard.js:132:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions…js (module.js:579:10)
at Module.load (module.js:487:32)

I"m stuck and trying to figure out what did you mean by “After installing the node trough npm:”

I found a file under Roaming named npm but its empty ,

Any input you can provide will be greatly appreciated

Best regards

Saad (ST2)

My fault, I was not correctly describing the process… you should install Node. npm comes together too. I used this as a guide:
https://docs.npmjs.com/getting-started/installing-node
but only for the part of installation of npm and Node.

After that you open the npm and install from there the bom wisard: C:\Users\pok>npm install -g --production kicad_bom_wizard
using this guide:
https://docs.npmjs.com/getting-started/installing-npm-packages-globally

And than you use the path where npm installed the bom wizard to make your command line in KiCad like described by the author of the wizard.

That is what I can supply as information, sorry! It was some time ago and I don’t remember very well the exact order, because I’am by no means specialist in this matter.

It will be very helpful if somebody more fluent in this aspect can construct some meaningful installation scenario for Windows 10, including the initial installation of Node and npm.

Best Regards!

Of course you must have already downloaded the installation package for the wizard somewhere, so that you can install it from there to some particular location on the disc, using the npm. Than the path of this destination must be used to compose your command line, like described before.

POK< many thank s for your help,I 'm going to try again, this way above my pay rate, will try again

For some reason I can’t install NPM (maybe) i tried to verify the version but it gave me error [ i ran node , i typed npm -v and i got an error message saying reference error npm is not defined

Pok, Many thanks , got it to work , Very happy :slight_smile::sunglasses:

@ST2 great to hear that you have it working. Sorry for the lack of reply unfortunately this is contract season for me and unfortunately my side projects usually are the first to go :frowning:

@Pok thank you

  • Ron

Thank you Ron, I really appreciate you sending this email to me and many
many thanks for all the fine and useful work you’ve done for this community

Best regards

Saad Thabit
Founder and Principal Engineer
DRF Engineering Services LLC.
860 Worcester Road| Suite 101
Framingham, MA.
01702508.314.0845thabit@drfengineeringservices.comwww.drfengineeringservices.com

https://www.facebook.com/DRF-Engineering-Services-1549921131971008/
https://www.linkedin.com/in/saad-thabit-481071a

Not sure you meant to send this message to the forum?

Hi All,

I’ve finished implement some new feature to the plugin and I was wondering if anyone fancy trying it out before the final merger for release?

Here’s what changed on 0.0.9 (peding release)

Added

  • Added support for options files. for now on any new features will be implemented and made configurble via the options file. this will also make it eaiser to have a standard setup between projects.
  • Added PDF support. the PDF generator uses html templates to create the PDF file.
  • Added HTML_PDF template for use with the PDF generator
  • Added BOM sort and the related configuarable settings. You can now sort ASC/DEC by ref, value and footprint.

Fixed

  • Fixed the issue where file names with space would break class tags
  • Fixed the missing filed header class tags

Here’s what the new PDF template looks like

and here the PDF example if anyone want to have a closer look.
kicad_bom_wizard PDF output hash Define electronics.pdf (138.3 KB)

Getting the dev code

To get access to 0.0.9 you will need to git clone the project and then checkout the develop branch.

git clone https://github.com/HashDefineElectronics/KiCad_BOM_Wizard.git
cd ./KiCad_BOM_Wizard
git checkout develop

then you will need to run the install

npm install -g ./

Using it

At this point, you should be able to use the plugin the same way as you did previously except that you can now pass it a config instead of a series of commands parameters.

you can find an example of the config file on the project root directory under Example/options.json.

Using the new config file, all you need to do is now call kicad_bom_wizard and give it the location of your config file.

kicad_bom_wizard CONFIG_PATH/options.json

where CONFIG_PATH is the directory to the options.json.

configuration file example

Here what the configuration file looks like. All path can be relative to the config file, relative your current working directory, relative to kicad_bom_wizard or absolute .

{
  "version" : 2,
  "outputType" : "pdf",
  "templatePath" : "HTML_PDF",
  "outputPath" : "../Test/.tmp/",
  "outputName" : "output.pdf",
  "input": "example.xml",
  "pdfOptions": {
    "pageSize": "A3",
    "printBackground" : true,
    "landscape": true,
    "marginsType" : "0"
  },
  "sort" : {"by": "ref", "ascending": true}
}
  • outputType needs to be either pdf or file. where file is that you intent to make you own text file. for example csv or html.

  • templatePath this is the path to your template file. This can either be CSV, HTML, HTML_PDF or a path to your own.

  • outputPath this is where you intend to save your output file

  • outputName this the name that you want to the output file to be called.

  • input this the path and name of your project xml file.

  • pdfOptions this are some of the options for configuring the PDF output if you are using PDF

  • sort by this sets the BOM component grouped sort order. You can set it too ref, value, value_num and footprint. where value_num means that the value filed is to be treated as numbers.

– Ron

2 Likes

Hi ! I’m getting the following error when attempting to use the BOM Wizard:

Command error. Return code 8

Info messages:
KiCad_BOM_Wizard Rev: 0.0.8

Error messages:

module.js:340
throw err;
^
Error: Cannot find module ‘xml2js’
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at ReadXmlFile (/home/grpace/Electronics/KiCad/BOM Wizard/KiCad_BOM_Wizard.js:433:16)
at Task (/home/grpace/Electronics/KiCad/BOM Wizard/KiCad_BOM_Wizard.js:608:7)
at Object. (/home/grpace/Electronics/KiCad/BOM Wizard/KiCad_BOM_Wizard.js:132:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions…js (module.js:474:10)
at Module.load (module.js:356:32)

Running Ubuntu 14.04
Is a re-boot necessary after installing nodejs ?

Greg