KiCad BOM Export Script

Hi

I’ve been working on a script for a while now to export a BOM in the format that I like, adn then to roughly cost it. I’ve seen the various threads on using third party products to translate the BOM into a format that is usable, but I wanted to try a little more.

Disclaimer - It’s still very ropey, and Python is not my “home language”.

However, I have got it working as an add-in from within EESchema, so that it:

  • Exports the standard BOM fields as well as any Template Field Names for parts
  • Groups the sames parts into a single row (optionally)
  • Connects to the SupplyFrame FindChips API to gather pricing

If this is something that interests you, jump over to my GitHub repo and give it a try. If you have the energy, please also contribute to make it better.

The Readme file covers most of the things I could think of, but post more if things aren’t making sense.

Enjoy
Andrew

Hi, Andrew. I had the same need as you for pricing my KiCad projects. I built a tool called KiCost that does the following:

  • Processes the BOM XML file from your KiCad schematic to create a part-cost spreadsheet by scraping the web sites of several popular distributors for price and inventory data (Digi-Key, Mouser and Newark/Element14 are currently supported).

  • The spreadsheet contains quantity-adjusted pricing from each distributor for individual parts and the total board.

  • Enter the number of boards to be built in a spreadsheet cell and all the pricing for the total board and individual parts is updated.

  • The spreadsheet also shows the current inventory on-hand for each part at each distributor.

  • Enter the quantity of each part that you want to purchase from each distributor and lists of part numbers and quantities will appear in formats that you can cut-and-paste directly into the website ordering page of each distributor.

I made a video showing how it’s used. I mentioned your program at the end as an alternative tool for pricing boards. I also plan to look over your code to see what ideas I can steal from it.

You can download my tool here or install it using pip.

1 Like

Hey Dave

Just back from vacation and had a look at your video - that’s really great. Apart from actually having a name for the tool (which is pretty cool), I like the way that you go beyond the initial costing to generate a complete workflow through to ordering.

I haven’t dug into your code yet, but thumbs-up for getting that screen-scraping working so well. I’m too terrified to try anything like that!

Thanks for sharing, it’s a great tool.
Andrew

Thanks, Andrew. The screen scraping isn’t too hard, but it is SLOW: it takes 1.5 minutes to scrape seven part numbers on all three websites. Using the FindChips API is a lot faster. Is there a limit on how many queries you can make to their API? (I know that the Octopart API limits you to 500 queries per month.)

Yes, there is a limit - 1,000 calls to the API a month. Next step up is 5,000 calls a month for $35. If I get to a point where I’m costing out 5,000 BOM parts a month, I’ll be a very happy (and very busy)!

But you may also cost-out 100 parts ten times per month, especially if you’re iterating a design. :slight_smile:

Perhaps I can use the FindChips API and then, once I reach my query limit, fail-over to Octopart. Then when I exceed my Octopart limit, I could fail-over to web-scraping.

Very cool! I’ve written a BOM-generator Python script which takes the Kicad BOM and compares it against my master parts list database (actually a spreadsheet) and it spits out a BOM against which I can order parts. Right now my parts list has a qty 25 price embedded which is close enough for small builds, but at some point I am going to make it smarter and use the Findchips API to use a real-time price based on actual quantities.

One of these days …

LOL,

One of my big problems with KICAD is the lack of extensions of the software to do things like this. I think I have written “parts”. One of the parts that I have written is a web scraper that kind of works for grabbing Digikey and Mouser prices, quantity, $ vs. qty, and lead times. This way I do not have to rely on Findchips or Octoparts for providing this data.

I’ll just leave this shameless plug here… >_>

The parametric search is a neat feature!

Very cool. Seems there is quite a demand (and number of solutions) for these kind of tools - I’m finding it really interesting seeing how others have tackled and implemented a solution.

Hi Dave,

I would like to use your KiCost Add-on with KiCad 4.0.0 rc1.
How can I install it on a windows7 based system?

Thanks for some hints in advance.

Cheers,

Aquila

All you need is Python. On Windows 7, I would recommend using WinPython 2.7, 32-bit version. Once that’s installed, then the command ‘pip install kicost’ should be all you need to do.

Hi Dave,

thanks for the fast reply.
OK, I am a complete noob considering python:
I downloaded Python and installed it. I started “WinPythonControlPanel”, clicked on “Advanced” ->“Open Console here”.
Then I entered “pip install kicost” and pressed return.
I got the message of “successfully installed future-0.15.2 kicost-0.1.10”.

Then I followed your kicost’s documentation.

  • I created a field called manf# and set the field value
    to the manufacturer’s part number for each part in my schematic.
  • I created a BOM file and found the corresponding .xml file in my project folder.

I got stuck at the step entering “python kicost -i schem.xml” into the command line.
I installed KiCost here: …\KiCad\kicost-0.1.10\kicost and tried to perform from this directory.
I got the message: “SystemError: Parent module ‘’ not loaded, cannot perform relative import”.
Maybe I missed something?

Cheers
Aquila

I installed kipart on ubuntu using easy_install - when I do

sudo easy_install kicost
Searching for kicost
Reading https://pypi.python.org/simple/kicost/
Best match: kicost 0.1.29
Downloading https://pypi.python.org/packages/09/73/ffab86d4c68b1f44ee2f83414cc6c3c885fbfe3822a3f2917ed3c04943fb/kicost-0.1.29.zip#md5=b20116914e34360be33bd787b4d80ace
error: Download error for https://pypi.python.org/packages/09/73/ffab86d4c68b1f44ee2f83414cc6c3c885fbfe3822a3f2917ed3c04943fb/kicost-0.1.29.zip#md5=b20116914e34360be33bd787b4d80ace: [Errno 101] Network is unreachable

I have network connectivity, but there seems to be some issue with python.org - Can some one help with overcoming this

The zip file is https://pypi.python.org/packages/09/73/ffab86d4c68b1f44ee2f83414cc6c3c885fbfe3822a3f2917ed3c04943fb/kicost-0.1.29.zip which looks right and downloads for me

As I type this, I ran easy_install again, as well as clicked on the link using the browser, both times out

Reading https://pypi.python.org/simple/kicost/
Download error on https://pypi.python.org/simple/kicost/: [Errno 101] Network is unreachable -- Some packages may not be found!
Couldn't find index page for 'kicost' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
No local packages or download links found for kicost

I then went to https://pypi.python.org/pypi/kicost/0.1.29 and downloaded it manually - that downloads.