BOM generation in "new" Kicad (Windows)

I am new to KiCAD, i followed the steps provided in this page. I am getting an error as follows.

Saxon-HE 9.5.1.9N from Saxonica
.NET 2.0.50727.5485 on Microsoft Windows NT 6.1.7601 Service Pack 1
URIResolver.resolve href=“file:/D:/Program%20Files/KiCad/bin/scripting/plugins/bom2csv.xsl” base=“null”
Using parser org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser
Warning: at xsl:stylesheet on line 35 column 80 of bom2csv.xsl:
Running an XSLT 1 stylesheet with an XSLT 2 processor
Stylesheet compilation time: 2028 milliseconds

Kindly suggest some solutions to rectify this problem and get BOM files

Thanks in advance

Sriniketh Ravindran

I got that “error” too, but check again. Right above that message, mine said “Success” and the CSV file was placed in my project directory. I didn’t see the “Success” message at first.

Anyway, thanks for the info, Dolganoff! It helped a lot.

For version 4.0.2-stable on Windows 7, here is how I used the already-installed xsltproc.exe and bom2csv.xsl: http://www.firstpr.com.au/kicad/#bomw

My command line is:

"C:\Program Files\KiCad\bin\xsltproc.exe" -o "%O.csv" "C:\Program Files\KiCad\bin\scripting\plugins\bom2csv.xsl" "%I"

I am completely new for KiCAD and just downloaded and installed yesterday! For BOM export, the existed menu is good but limited. Therefore I like to work on the original native data as a .net developer. I found the schematic diagram data is in text format instead of common xml file. So, I write a code to generate Bill of Materials (BOM) from .sch file where I can add my own filters inside. it works well even for hierarchy design. But I do hope the file format (schema) keeps unchanged when new version comes.

Did you check the various BOM generators mentioned on here ?

If you installed this yesterday, and already coded and tested a BOM, that is impressive :slight_smile:
What is this BOM generator written in ?

Chance of no changes is zero.
I would expect the SCH format to change to be similar to PCB, but that is easier to parse than SCH.
It would be easy to check for two formats, and support both eventually.

1 Like

In my opinion it makes no sense to parse the schematic file, a format that can/will change. The schematic file contains a lot of information that is not relevant to a BOM so parsing it to obtain BOM data is not very efficient. Eeschema will happily write the relevant data to an XML file for you. Even if you prefer to write your own application instead of using a plugin I don’t understand why you wouldn’t use the XML file.

I think there is a place for all approaches.
Sure, use XML, if that will do what you need, but sometimes that is either not enough, or requires an additional step that a user may wish to avoid.

KiCad will always use ASCII files, so the OP can modify the parser, when the next major upgrade of SCH side is done.

I disagree completely, pursuing “all approaches” usually does not end well. That is why standards are developed in the first place.

How can it not be enough? It would appear your could rebuild the schematic from the XML file. It is also extensible after all. Often all you need to manipulate the data is a stylesheet but it is also easily read by other applications, due to the fact that it is a standard. And surely using externals tools would require more steps beyond the simple click of a button.

Yes, I have tools like that. Often when the toolchain is updated the third party tools break and you have to wait for them to be updated, assuming they are still being maintained. Let’s not take KiCad down that road.

I’m not sure where you get this ‘standard’ from, XML is merely a format, and has nothing to do with what is actually contained in the file.
I can see 4 BOMs already, in kiCad - seems there are at least 4 ‘standards’ !
( & more are posted on here…)

This requires that someone to find and choose the correct and matching BOM script, (already there are 4, but those may need modification, making 5 or 6…) in order to ensure the BOM file is in phase, and then their external software must be run, to do the post-processing.
So there is another step, which is hard to guarantee has happened.
To me, it can be simpler to parse the Schematic file directly, less steps and less variables. One master.

Users are free to choose the flow that suits them best.

Precisely. it is a standard format, parsable by any XML parser regardless of content. Tools already exist, most of us already have them, to manipulate the content of an XML file using stylesheets. If that’s not good enough for you then by all means write an application to use the contents of the XML file as you see fit. Changes to the XML file are unlikely to break any stylesheets or applications that use it, unless they decide to rename/remove existing elements which would not be a good idea but still manageable.

Parsing the schematic is not only not a good idea it’s simply not necessary. Using an external app to parse a schematic file requires that you remember to save the schematic first. Generating the XML from within KiCad does not.

Those “BOM scripts” you refer to are the stylesheets I am referring to. It wouldn’t matter to me if there were 40 of them. Once I find the one that works for me I stick with it. One button click and I get both files guaranteed to be in sync with my schematic. If there isn’t a stylesheet that does what I want I find the closest one and modify it, now there are 41 so what?

Anyway, I’m not here to argue for the sake of arguing, I have stated my opinion as to why I believe it is both silly and unnecessary to reinvent the wheel. You are of course free to do what you like.

1 Like

?? That seems quite a strange ‘plus’ point. What sane person would not save changes, when running a BOM ?

I can edit a SCH and when I save that SCH, the change is saved, just as common sense would expect.
I can email that saved SCH to someone else. They have all the information.
However, the XML file I have, does not update, until I manually run something else. This requirement you select and run something else, is a significant weakness.
Even within KiCad, the means to refresh that XML is not explicit. There is no Export XML button.

Whether it makes you sane or otherwise, the fact is it would be possible to have a BOM out of sync with your schematic.

The same is true of netlists, you do generate netlists don’t you? Would you like them to be out of sync with your schematic because (sane or not) you didn’t save the schematic first?

No there isn’t, the button is in fact called “Generate” it is in the BOM dialog just as the “Generate” button in the NET dialog.

Below is just for open discussion:

I am working in a engineering software company which helps synchronize the CAD data to ERP data automatically. Some customers would like to have the BOM data from schematic diagram while others prefer getting from PCB. Data in ERP is very important for costing and purchasing, Therefore the compatibility between CAD versions is also critical when the CAD is upgraded. Attached is my intial result from KiCAD while more customized fields will be added. Maybe I have not played KiCAD well yet.

I think it is better if the project can be saved in xml format when the end user hits the Save button (for both SCH and PCB, easier to be parsed even if more functionality is increased). Now you need export xml file manually then do something else which many of my customers do not like.

PartNo Desc Qty RefDes
complex_hierarchy Main 1
CP 10uF 1 C10
CP 10uF 1 C11
7805 78L05 1 U2
ICL7660 ICL7660 1 U1
CP 47uF/63V 1 C9
CONN_2 CONN_2 1 P1
CP 47uF 1 C1
Test 47uF/20V 1 C2
D_Small 1N4007 1 D1
CONN_2 CONN_2 1 P2
R 220K 2 R26,R28
R 47 2 R25,R27
D_Small 1N4148 2 D8,D9
R 5,6K 2 R10,R20
C 150nF 2 C12,C14
R 1K 2 R23,R24
MPSA42 MPAS42 2 Q6,Q2
MPSA92 MPAS92 2 Q7,Q3
D_Small 1N4148 2 D7,D4
MPSA42 MPAS42 2 Q8,Q4
D_Small 1N4148 2 D6,D3
R 470 2 R13,R3
D_Small 1N4148 2 D5,D2
R 220K 2 R14,R4
R 1K 2 R18,R8
R 220K 2 R22,R12
R 1K 2 R19,R9
CONN_2 CONN_2 2 P5,P3
R 22K 2 R16,R6
LM358N LM358N 2 U4,U3
CONN_2 CONN_2 2 P6,P4
C 4.7nF 2 C7,C4
C 820pF 2 C8,C5
R 47 2 R15,R5
R 4,7K 2 R21,R11
MPSA92 MPAS92 2 Q5,Q1
LM358N LM358N 2 U4,U3

PcbNew “knows” about accessories not shown on the schematic eg heatsinks, fixing screws.
These are all essential for the ERP

Yes. PCB can have more components. But SCH can have more properties generally, such as ErpPartNo, Vendor, VendorPartNo.

Manufacturing company generally also has another mechanical CAD (Solidworks, Inventor,…) to handle these accessories together with other mechanical parts…

You are right. Some like to work on PCB.

I looked into more. It will be great if the corresponding SCH properties can be displayed in PCB Footprint Properties interface and Python API can get these data in the Modules as it is so simple to handle it.

import pcbnew
pcb = pcbnew.GetBoard()
for module in pcb.GetModules ():
print (module.GetReference () + " " + module.GetValue ())

I agree this would be useful, but for now PcbNew has limited Fields and export.

Wishlist nice would be something like
sch = pcbnew.GetSch()
I wonder how hard it would be, to have Python access into the SCH data base, and to trawl both ?
Is this on the SCH roadmap ?

Given the present state of kiCad where SCH allows more fields, than PCB, this could require a dual-export, as a work around.

ie PcbNew can export netlists, or reports, and give RefDes Value Footprint,

If that is also read by the BOM manager, it can check for PCB centric BOM-Valid items, and merge those with the SCH info. (eg include heatsinks, hardware, but skip fiducials, test points )

Not forgetting the PCB(s) themselves should also have order codes.

1 Like

Thanks for your responses. That would be a nice roadmap.

Hi akouz!! I had allok to your BOM extractor and It is very interesting but how it works the inventory? From the code I saw that the extractor opens a file calle INENTORY\inventory.ini but that file does not exist. Which is the syntax of the inventory file?
I opened a kicad schemati and I see my bom but what about the inventory? it is a kind of database that I can create so I can have price updated of all components?

Thanks in adance,
Regards,
Corrado

Hi,

I am also getting the error “Command error. Return code 11” while trying to generate BOM on a recent nightly build (2016-12-22 revision d365dc5) on Win7-64 pc.

But when I opened another project created using a 2 months old nightly (i don’t remeber the version info) in the same 2016-12-22 revision d365dc5 the BOM generation is working.

I did’t get a clue what exactly is happening/cause for the error in the current project ( and why the old project is able to generate bom).

can anybody please clarify this. ( am planing to install the Saxon as @Dolganoff suggested)