KiCAD Mouser & Digikey integration

I want to create a plugin for the KiCAD EESchema editor that would allow opening an integrated store (like Mouser or Digi-Key, LCSC & etc.) directly inside the program, searching for a component there, and importing its Name, Datasheet, Description, Mfr. No., and Manufacturer into the Symbol Fields. That way, the only remaining step would be to generate a BOM file and place an order.
The problem appeared at the stage of connecting these two programs. At first, I thought about making the interface in Python, but from what I’ve found, EESchema in KiCAD does not support plugin integration directly. The only option left seems to be editing the source code and compiling it myself.

I found the file kicad-source-mirror/eeschema/dialogs/dialog_symbol_properties.cpp, and as far as I understand, this is the file responsible for rendering the window where I need to add one button and a function that would receive the exported Attribute Search values of the selected component from my program.

However, I can’t compile it, because as soon as I include a single header file through CMake, a bunch of other dependencies show up, and some header files are also missing, which only exist during the full project build. In the end, I realized that I need to compile the entire project — but the problem is that it takes a very long time.

Does anyone have an idea how to make a test dialog window (dialog_symbol_properties) so that it can be debugged easily, and eventually, once everything is ready, I could just copy the code into the full KiCAD project?


2 Likes

Are you aware of KiCost?

It is/was a plugin (or standalone script?) that could pull cost and other data from various sources. As far as I know the manufacturers use various methods to block such automated approaches. I never used it myself, but maybe it’s useful for you to have a look at that source code.

Edit: I assumed that just mentioning the magic name was enough of a hint to start a search such as:

https://forum.kicad.info/search?q=KiCost

And finding things like:

2 Likes

I think it was @devbisme that started KiCost and stopped when they started demanding accounts/keys/whatever to do this? I think someone picked it up but I’m not sure.

How about creating a plugin for pcbnew?
All you need to do is create a GUI that lists existing BOMs in a table and processes only specific columns, then either revert to the original or output a different BOM when you’re done.

@ivixiz
I agree that this would be a nice addition to the schematic interface, rather than the PCB. Usually I have a good idea of what part I want when designing, but then have to open a browser and find that part on LCSC/Digikey/Mouser, and then manually copy all the relevant numbers across.

My workflow exclusively involves “update PCB from schematic” with the “match by designator” option. I have not once gone back the other way as there are often ‘idiosyncrasies’ with my PCB components that would royally mess with my schematic definitions.

Doing what you suggest would not fall into the category of ‘scraping’ a website because it only targets single parts, and in fact would probably end up less of a hit on a suppliers website than otherwise. For example, if I want a 10K 0603 resistor, I search for a 10K 0603 and then first select ‘resistor’ (just try “10k 0603” on Digikey and you get resistors, capacitors, thermistors, inductors, and a slew of other things) shuffle my way through tolerances, materials, ratings and manufacturers, weeding out things like “I want 0603 imperial, not 0603 metric” before finally arriving at a part that is in stock (and will likely remain in stock until I place an order).

I haven’t used ‘kicost’ and can’t make any comment on how it searches for parts and back-annotates that into a design (or if it attempts to back-annotate at all).

Can’t help you with the scripting - sorry - although not having a scripting interface for schematic (when one exists for the PCB) seems a strange design choice for KiCad development!

A post was split to a new topic: KiCad Parts