Buy Magic Mushrooms
Magic Mushroom Gummies Best Amanita Muscaria Gummies
Nov 032013

Photo by

I’d like to share a neat Eagle hack for all our the people who have taken our Eagle CAD classes (myself included) and our Eagle-using friends.

BOM-EX is nifty little ULP (User Language Program) that extends the functionality of the built-in BOM ULP. BOM-EX not only helps you assemble a coherent BOM (Bill of Materials) right from your Eagle schematic, but it also makes it easy to assemble a database of parts, and associate those parts with parts numbers for DigiKey, Mouser, Newark, etc.

I made a nice little script that lets me build my BOM database without ever leaving the DigiKey website…

My usual process for selecting parts goes something like this:

1) Drop a part in the schematic.
2) Check to see if this part (in this size) exists, is available, is affordable, etc.
3) No? Keep looking.
4) When the project is done, go back and find every part again.
5) Assemble a BOM by hand, or spend time cleaning up the output from BOM.ulp.
6) Punch everything in to DigiKey, triple check to see what I forgot, etc.
7) Place the order, hope I didn’t forget anything, hope I ordered enough, etc.

BOM-EX makes things much simpler; I wish I has been using it from the start:

1) Find the part on DigiKey, etc.
2) Drop it into BOM-EX
3) When the project is done, export a BOM file that can be uploaded straight to DigiKey, Mouser, etc.
4) Order your parts with confidence!

But wait, how can we make this even simpler? How about populating our database straight from DigiKey?

First make sure you have BOM-EX set up. You can download the latest version of BOM-EX from Cadsoft’s webpage. Search for BOM-EX and download the latest version (bom-ex156 as of this writing). There’s a nice tutorial for setting it up here, and also a nice PDF included with BOM-EX itself.

Choose a location for your parts database file to live – it can be inside your Eagle project folder, but I recommend keeping it global, so you have an easy-to-reference library of common components for all your projects.

Next, download our Grab-Bag repository and find the python script in the Bom-ex folder. Open the script and change the PARTSDB path to point to where you keep your parts database file.

You can now add parts to your database file straight from the command line:
python ATMEGA644A-AU-ND
will add the following line to your parts database file:

Note: you may need to install the BeautifulSoup module for Python. You can install it with pip install beautifulsoup4 or easy_install beautifulsoup4. It’s also available as the python-beautifulsoup4 package in recent versions of Debian, Ubuntu, and Fedora, or you can download it from their website.

For extra coolness, drop into /usr/local/bin (or anywhere else in your PATH, make it executable (chmod +x, and now you can run it from anywhere.

But wait, there’s more! If you’re on a Mac, grab the Add Parts To Library.workflow file in the repository and double-click. Select Open With Automator

Screen Shot 2013-11-03 at 2.09.51 PM

If you followed the above instructions, you shouldn’t have to change anything, otherwise update the “Run Shell Script” box in Automator to reflect the correct location for your script. Close Automator, double-click on the workflow again, and select Install.

Now, when you’re browsing the DigiKey website, just right click on the DigiKey part number, select Services, and select Add Part to Library

Screen Shot 2013-11-03 at 2.13.24 PM

Et VoilĂ , your parts are appended to your BOM-EX parts database, no manual entry required! Enjoy a few hours saved in BOM-hell on your next Eagle project. See this tutorial for more information on using BOM-EX.

Do you have any slick Eagle hacks? Share them in the comments!

 Posted by at 2:26 pm

  8 Responses to “Streamline your parts ordering process through Eagle!”

Comments (8)
  1. The python script wont work for me. I used your example of ATMEGA644A-AU-ND and it’s giving “none” for all values aside from that part number.

  2. @jon_fraser:disqus Looks like because digikey recently attempted to add some more Javascript which broke parsing you need to use the html5lib parser for this script. To do that get the parser with easy_install html5lib then change the line that reads soup = BeautifulSoup(data) to soup = BeautifulSoup(data, ‘html5lib’).

    Hope this helps.

  3. I think I followed all the instructions (thanks!), but when I try to add the part via the Services – Add to Parts Library nothing actually gets added. I don’t get any errors popping up that tells me something is wrong. Also, it works when i can add from command line. What am I missing?

    • First, this appears to be a Python 2.7 script (need to know this in order to know which version of python to install). When run, this is the error:

      Traceback (most recent call last):
      File “”, line 24, in
      partNo = sys.argv[1]
      IndexError: list index out of range

      When I change this from sys.argv[1] to sys.argv[0], I get this:
      Traceback (most recent call last):
      File “”, line 33, in
      data =
      File “”, line 410, in open
      response = meth(req, response)
      File “”, line 523, in http_response
      ‘http’, request, response, code, msg, hdrs)
      File “”, line 448, in error
      return self._call_chain(*args)
      File “”, line 382, in _call_chain
      result = func(*args)
      File “”, line 531, in http_error_default
      raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
      HTTPError: HTTP Error 404: Not Found

      I think DigiKey has changed the format, somehow and the script is not aligned to the change.

  4. I had similar problems but was able to get it to work. First, html5lib needs to be used as Paul Ryan wrote. Second, the reason it worked from command line but not from the Services – Add to Parts Library was because the input argument for Services was a url, whereas by command line, it is a part number that gets converted into a url.

    To solve, I modified the python code:

    if “http://” in partNo:
    url = partNo
    url = DIGIKEY_URL + partNo.replace(“/”, “%2F”).replace(“#”, “%23”)

    And later, to get the correct partNo (note ‘contents[1]’):

    # Parse out the PartNo
    for elem in soup(text=re.compile(r’Digi-Key Part Number’)):
    parent =
    partNo = parent.contents[1]

    Thanks a lot for this very convenient tool!

  5. I made a quick GUI to go along with this, located here:

  6. As of 6/2/17, the script does not work with how Digikey’s website is constructed.

  7. I have tried this on digikey website and it works fine but you must right click on the digikey part number and it will add it to the partsdb.txt

    if an error occurs unable to find bs4 use pip to install beautifulsoup4

    pip install beautifulsoup4

    on the command line you must have an argument with a valid digikey partno
    for example:

    which is

    if no part number then error message appears:

    IndexError: list index out of range

    if the manufacturers part number is used such as in my example ATMEGA328PB-AUR (no RCT-ND) is used it will give an error

    HTTPError: HTTP Error 404: Not Found

    because it is looking for the digikey part number.

    Add to parts library service
    Using homebrew version of Python v2.7 and it was not working with /usr/bin/python needed to use the full path as shown below:


    and using the full path to the script:

    /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/Resources/ /[FULLPATH]/ $1

    replacing [FULLPATH] with the location of the file.

    Ensure the has the full path to the partsdb.txt

    PARTSDB = “/[FULLPATH]/partsdb/partsdb.txt”
    replacing [FULLPATH] with the location of the file.

    The script needs more error checking if no argument given.
    or a message saying “must provide a valid digikey part number”
    a partial search for part number with a interactive selection of what to add
    use of a config file for PARTSDB variable
    a check to ensure BeautifulSoup library is installed.
    a check to see if argument given is digikey or manufacturers part number and first try for digikey and a fallback for manufacturers part number

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>