KiBoM - Python BOM Generation tool

Hi @Martin123 I’ve fixed a few similar errors recently - it would appear in this case that the schematic version text contains some non ASCII characters (or the schematic file name itself).

Can you post the contents of your schematic filename and version / revision string so I can run some tests here and fix the issue?

Thanks for the quick reply.
I just sent you the entire project in PM

Martin

Thank you for this plugin which is very helpfull.

I added the fiel Config and the value +test in one of my componant and when I do
python “C:\Users\myUserName\Downloads\KiBoM-master/KiBOM_CLI.py” “%I” “%O” -r test
or
python “C:\Users\myUserName\Downloads\KiBoM-master/KiBOM_CLI.py” “%I” “%O”
it appears or not in the BOM file.

However, I tried -test and either I do
python “C:\Users\myUserName\Downloads\KiBoM-master/KiBOM_CLI.py” “%I” “%O” -r test
or
python “C:\Users\myUserName\Downloads\KiBoM-master/KiBOM_CLI.py” “%I” “%O”
I never have the component in the BOM file.

Did I do something wrong ? Is it a bug ?

Also is it possible to have several variants by writing +test -prod for a same component ? I tried it but it did not work.

I’m not sure if this is a good place for this question.
I just started to use this tool and the first project I tried barfed. Apparently it didn’t like the part because it’s an alias. Here’s the section in the library that shows this part:

QUAD_OP-AMP

DEF QUAD_OP-AMP U 0 20 Y Y 4 F N
F0 “U” 0 200 50 H V L CNN
F1 “QUAD_OP-AMP” 0 -200 50 H V L CNN
F2 “” -50 100 50 H V C CNN
F3 “” 50 200 50 H V C CNN
ALIAS LM324 TLC274 TL074 LM324N LM324AN MCP6004
$FPLIST
SOIC*
DIP*
TSSOP*
SSOP*
MSOP*
$ENDFPLIST
DRAW
P 4 0 1 10 -200 200 200 0 -200 -200 -200 200 f
X V+ 4 -100 150 0 D 0 50 0 1 W
X V- 11 -100 -150 0 U 0 50 0 1 W
X ~ 1 300 0 100 L 50 50 1 1 O
X - 2 -300 100 100 R 50 50 1 1 I
X + 3 -300 -100 100 R 50 50 1 1 I
X + 5 -300 -100 100 R 50 50 2 1 I
X - 6 -300 100 100 R 50 50 2 1 I
X ~ 7 300 0 100 L 50 50 2 1 O
X ~ 8 300 0 100 L 50 50 3 1 O
X - 9 -300 100 100 R 50 50 3 1 I
X + 10 -300 -100 100 R 50 50 3 1 I
X + 12 -300 -100 100 R 50 50 4 1 I
X - 13 -300 100 100 R 50 50 4 1 I
X ~ 14 300 0 100 L 50 50 4 1 O
ENDDRAW
ENDDEF

And here’s the message:

python “C:/SVN/KiCAD/KiBoM-master/KiBOM_CLI.py” -v “C:/SVN/KiCAD/Projects/TCU-Steering-Copy/TCU-Steering.xml” “C:/SVN/KiCAD/Projects/TCU-Steering-Copy/TCU-Steering”
Input: C:\SVN\KiCAD\Projects\TCU-Steering-Copy\TCU-Steering.xml
Config: C:\SVN\KiCAD\Projects\TCU-Steering-Copy\bom.ini
missing libpart for ref: U36 TL074 TCU-Steering-cache
Excluding ‘MK1’: Field ‘Part’ (Mounting_Hole_PAD) matched ‘mount.*hole’
Excluding ‘MK10’: Field ‘Part’ (Mounting_Hole_PAD) matched ‘mount.*hole’
Excluding ‘MK11’: Field ‘Part’ (Mounting_Hole_PAD) matched ‘mount.*hole’
Excluding ‘MK12’: Field ‘Part’ (Mounting_Hole_PAD) matched ‘mount.*hole’
Excluding ‘MK2’: Field ‘Part’ (Mounting_Hole_PAD) matched ‘mount.*hole’
Excluding ‘MK3’: Field ‘Part’ (Mounting_Hole_PAD) matched ‘mount.*hole’
Excluding ‘MK4’: Field ‘Part’ (Mounting_Hole_PAD) matched ‘mount.*hole’
Excluding ‘MK5’: Field ‘Part’ (Mounting_Hole_PAD) matched ‘mount.*hole’
Excluding ‘MK6’: Field ‘Part’ (Mounting_Hole_PAD) matched ‘mount.*hole’
Excluding ‘MK7’: Field ‘Part’ (Mounting_Hole_PAD) matched ‘mount.*hole’
Excluding ‘MK8’: Field ‘Part’ (Mounting_Hole_PAD) matched ‘mount.*hole’
Excluding ‘MK9’: Field ‘Part’ (Mounting_Hole_PAD) matched ‘mount.*hole’
Traceback (most recent call last):
File “C:/SVN/KiCAD/KiBoM-master/KiBOM_CLI.py”, line 124, in
groups = net.groupComponents(components)
File “C:\SVN\KiCAD\KiBoM-master\bomlib\netlist_reader.py”, line 426, in groupComponents
g.updateFields(self.prefs.useAlt, self.prefs.altWrap)
File “C:\SVN\KiCAD\KiBoM-master\bomlib\component.py”, line 471, in updateFields
self.fields[ColumnList.COL_REFERENCE] = self.getAltRefs(wrapN)
File “C:\SVN\KiCAD\KiBoM-master\bomlib\component.py”, line 431, in getAltRefs
return S.flush(’ ', N=wrapN)
File “C:\SVN\KiCAD\KiBoM-master\bomlib\component.py”, line 347, in flush
if N!=None and c%N==0 and c!=0:
ZeroDivisionError: integer division or modulo by zero

Does anyone know how I can fix this problem?

Hi @kcminer this is a new one. I’ve just made a commit which should fix this, please grab the latest version of KiBOM and see if it works for you now…

1 Like

Thank you for the swift response. Unfortunately, this didn’t seem to fix the problem. However, the problem may be elsewhere. I replaced the part with a same part from the regular library and the problem went away. It generated a different entry in the library cache. Somehow the library cache may have been stuffed with wrong information.

While playing with the bom.ini file, I noticed that if I set ‘use_alt’ to 1 it generates a divide by 0 error. That’s ok though since I just wanted to see how this behaved and I can live with this set to 0.

This is a great addition to Kicad’s built-in scripts. I wish it’s incorporated into the released version.

Thanks SchrodingersGat! After years managing with kifield, we’re now expanding our BOM repertoire to make ordering with a quantities column easier. All the built-in BOM plugins were disappointing, but KiBoM is filling the gap.

We were able to work around the focus on Part/Lib/Value fields by simply removing/adding them to/from the relevant parts of the ini file.

The only thing I wasn’t able to work around was the implicit reference to the Description field. In our case, our parts have a custom field called Description which is used to describe the part. The KiCad one is used to describe the symbol (and is meaningless as far as our BOM is concerned). Is it easy to use ours instead of the KiCad one, or have we backed ourselves into a corner by naming our field Description?

@Heath_Raftery using custom fields with the same names as the default fields will cause issues. Easiest workaround is to simply change the name of the custom fields :slight_smile:

Hi, I know this is a really old thread, but I just downloaded the KiBoM package for the first time today and there’s no KiBoM_CLI.py file in it. Couldn’t find any in the listed folders on GitHub either. Was the file renamed, or is there another file we could use?

Hi @rauty - the script has been updated and is called in a different way now - see the new instructions here

1 Like

Hi, your link just brought me right back here. I’ve searched for another thread with this topic and can’t find one. Can you resend a better link please?

Hi, I cannot see the file KiBoM_CLI.py either and in the new instructions you indicate that it should be opened. Any hints to open/run the script?

Updating on a new machine myself, and the link above (“new instructions here”) is broken @SchrodingersGat.

I think one of the disconnects is that the “+” button on the Bill of Materials dialog is expecting to point to the file where you are running the plugin from (since it expects and XSLT or whatever).

So I just clicked the plus button, chose a dummy file of my own creation (empty file named KiBom) and then I changed the command line command to be what it recommends in the #Usage section that was linked above. This is still pretty unclear in the README.md, and I would recommend modifying it for clarity.

I have made a few changes which should help users having issues here:

Reverted to KiBoM_CLI.py file

I initially moved away from using this file when I implemented KiBoM as a PIP package. However as KiCad ships with its own copy of Python (which is difficult to install PIP into) I’ve decided it is simpler to support KiBoM as a static set of files.

Updated Documentation

The documentation has been updated and should now be much easier to follow.

Please let me know if there are still any issues or confusing points.

Cheers

1 Like

Thanks for the update and for the great plugin. One of my favorites!

Just discovered KiBOM and must say that the tool does just what I needed. Thanks!

A post was split to a new topic: Creating .xlsx files with KiBoM

It’s better to start a new topic as this one is about 3 years old. Hopefully the author will see the new topic.