BOM generation in "new" Kicad (Windows)


#1

As most of us know, the new kicad distribution doesn’t generate ready to use BOM files anymore, the docs only give suggestions on how to set up xml/xsl transformation with xsltproc. ( https://answers.launchpad.net/kicad/+faq/2265 )
The xsltproc is linux-native and I’ve found it painful to install on windows where I do most of my kicad work.

So I did a little bit of research and came up with an alternative solution, using “saxon” xml engine as xsl processor.

Here are the steps necessary to make it work in recent kicad versions (about bzr5000 and upwards)

  • download Saxon “home edition”, get the dot.Net version “SaxonHE9-5-1-7N-setup.exe” from http://sourceforge.net/projects/saxon/files/Saxon-HE/9.5/

  • install it somewhere, for example in “c:\saxon” folder

  • Open Eeschema, go to “Tools > Generate Bill Of Materials” menu

  • Choose “Add Plugin” button and name it whatever you want, I named mine “saxon bom”

  • you’ll be back in the BOM window, there in the command line field put this line:

    “c:\saxon\bin\Transform.exe” -t “%I” -xsl:“d:\kicad-winbuilder-3.4\kicad\bin\plugins\bom2csv.xsl” -o:"%O.csv"

  • replace “d:\kicad-winbuilder-3.4\kicad\bin\plugins\bom2csv.xsl” by the path to bom2csv.xsl proper to your installation.

Now, every time you click “Generate” button, the plugin will create a csv file with a BOM like in the old Kicad versions.


BOM -> I/O error : Invalid argument
Problem with BOM Generation
Command error. Return code 11 to generate BOM
Command error. Return code 11 to generate BOM
#2

Hi

Thanks for the solution. What version of Kicad are you using? I’m on BZR-5228 and there doesn’t seem to be a BOM2CSV file anywhere in the installation folder - or in fact even a plugin folder. Is this part of a “standard install” (whatever a standard install might be :smile:) or do I need to get this from somewhere else?

Thanks!


#3

Hello, @crashbang_proto
If you build your Kicad from sources, the xsl files should be in the source tree at least, on my install it is in kicad-winbuilder-3.4\src\kicad\eeschema\plugins
If you install from the binary package downloaded from nosoftware.cz, this install, indeed, doesn’t have plugins bundled for whatever reason; in this case you can get them from official github mirror here:


#4

Great, thanks @Dolganoff. I was indeed using the windows build off nosoftware.cz (so much faster to install than the build from source). Will check out the github link, thanks.


#5

All I’m getting is a xml file that is unreadable.

Here is my command line:

“c:\Program Files\Saxonica\SaxonHE9.5N\bin\Transform.exe” -t “%I” -xsl:“C:\Program Files (x86)\KiCad\bin\Plugins\bom2csv.xsl” -o:"%O.csv"

What am I doing wrong?
Thanks


#6

Is your bom2csv.xsl file actually there in the Plugins folder?
If yes and the command line still doesn’t work, I’d try to install saxon into folder without spaces in its name.


#7

Thank you for your quick reply.
Yes the bom2csv file is in the plugin directory. I downloaded it from github and pasted it there.
I tried installing saxon to c:\saxon, again without success.


#8

Ok, I reinstalled saxon just in c:\saxon
I also reinstalled KiCad in C:\KiCad so there are no spaces in directory names.

I finally got a screenshot.
Here is what I got from Saxon.

URIResolver.resolve href=“file:/c:/KiCad/bin/Plugins/bom2csv.xsl” base="null’
Using parser org.apache.xerces.jaxp.SAXParserImp1$JAXPSAXParser
Error on line 34 column 71 of bom2csv.xsl:
SXXP003: Error reported by XML parser: Attribute name “data-pjax-transient” associated with an element type “meta” must be followed by the ’ = ’ character.
Failed to compile stylesheet. 1 error detected.


#9

Can you share your xsl somewhere? I’ll try to compare it to mine, looks like the parser thinks the xsl is broken.


#10

It was a fresh download today.
I uploaded the bom2csv.xsl here:

http://s000.tinyupload.com/index.php?file_id=91765626265131340123


#11

Oh, this file isn’t an xsl at all, you’ve downloaded the html of the github page where the xsl file resides. To have the file, while in https://github.com/KiCad/kicad-source-mirror/tree/master/eeschema/plugins don’t do “save as” over the link because the file is not directly there but one step further. folow the link first and then click “Raw” button to download the original.


#12

Thank you,
Now it is running through but all I get is an empty csv file


#13

Was the xml source file generated though? Does it correspond to your schematics? It should contain all the components and nets.


#14

When opening the xml file, OpenOffice Calc gives a General Error and shuts down.


#15

Why open office? Text editor should be enough.


#16

That was just the default program for xml. Looks like everything is in the xml.

http://s000.tinyupload.com/index.php?file_id=03517736531718361445


#17

your xml processed fine on my pc.

try to expand the command line with real file names and run the command from the command line outside of Kicad, to see what messages pop out.

On my windows station the command resolves to:
“c:\Saxon\bin\Transform.exe” -t “d:\temp\1\inLOOP New Pro_Comm Sound Board-.xml” -xsl:“d:\kicad-winbuilder-3.4\kicad\bin\plugins\bom2csv.xsl” -o:“inLOOP New Pro_Comm Sound Board-.csv”

inLOOP New Pro_Comm Sound Board-.csv (3.5 KB)


#19

Thank you for all your help. I finally got it all correct. I appreciate your time. Thanks again.


#20

Thanks Dolganoff for this tip and the detail of your explanation. Got it going first time in BZR5380, constructed using winbuilder. I found the bom2csv.xsl plugin hiding in kicad-winbuilder-3.4\src\kicad\eeschema\plugins.

Cheers! Geoff


#21

I tried saxon, but it does not really work well for me, so I took some time ‘installing’ xsltproc.
I made a package with all necessary stuff and uploaded it to this forum, have a look at this post:
BOM grouped by reference

Enjoy!