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

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

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!