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

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

Hi Ronald.

One more thing, would be better if you could set up the order of the new headers you have created in sch file.
If I create two more fields like “Package” and “Info”, when the BOM is created the order of them seems to be alphabetical cause Info appears first (left) than Package,
You could use the order they are created in part configurations, like field4,… field5 etc… . or another way that be able to set up the orderr.

I did some customization and until now, the plugin is terrific I just try the HTML, I do not know if CVS is OK, congratulation and thanks.

Hi.
The CSV mode works great, I only removed the footprint field in row.conf. add two more fields. But for whom will use this field, need to add a comma between in row.conf in order to generate a correct csv file.

@Claudio_Cardoso You are right the fields are alphabetically order. I did it to ensure that all BOM output have a predictable format every time.

Without sorting, the problem is that there could be a chance that the order of some of the component’s custom fields can be different from the rest of the components in the BOM. The plugin can only build the fields tables in the sequence that it first finds them and so if the first component that it reads has a different order that the rest of the BOM then that is what it will use to output. This also means that you will need to ensure that all of your components follow the same fields order in order to ensure that the BOM outputs a predictable format every time.

I’m not sure what would be the best cause of action.
At the moment, I’m thinking that it might be worth adding another template file that defines the order that you want the fields to appear. This could give you the control over how the BOM output but at the same time no restricting how the components are created.

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