Seems like your tool would be able to do what KiCost is currently lacking… a simple way to get the manufacturer ID etc into KiCAD.
You might want to try to contact @devbisme and see if you two can go along and collaborate: Latest version of KiCost: Faster! Custom Pricing!
As for ideas for improvement… the important thing I’m interested in would be to make it work on local libraries too. Not just in eeschema, but also in the schematic library editor/browser.
If I am to put in this kind of data I would want to have it editable conveniently in the libraries, I wouldn’t want to fill these fields in via KiCAD means in the lib editor even as it’s just too much clicking and error prone.
I think if we had a generic Python module for writing info from CSV and/or XLSX files back into SCH and LIB files, then everybody would be able to make convenient front-ends for updating the schematics.
Edit it in a spreadsheet program (Excel, Calc) or as text. You can add columns (Manufacturer, Voltage specs, …)
Save it back as .tsv/.csv (tab separated values, this is the easiest export of spreadsheet programs)
Run ./tsv2sch.py exported_file.tsv kicad_sheet1.sch kicad_sheet2.sch to import the changes back into KiCad.
Faster way to update all your project sheets: ./tsv2sch.py exported_file.tsv project/*.sch
You can customize some of the script (columns to ignore for instance).
That looks like a good, running start on what’s needed! I can use some of that in KiCost to update schematic fields as @Joan_Sparky requested. Thanks for posting it.
@Andy_P master spreadsheet sounds like a neat way to deal with reusing parts for different projects. I’m going to give that one a try. However, I think that symbols/libraries should contain generic components and not my custom PNs- exactly for the reason you mention later (multiple sources for jellybean parts). IMO, what can be specified in a single source (schematic) should be saved there.
I might even argue that pcb layout is more appropriate place for this (for example SMD and TH layout versions for the same schematics) but pcbnew doesn’t have much support for module fields.
@devbisme I heard KiCad development team has plans for python scripting in eeschema, just like it is for pcbnew. And a new format for eeschema files (for better or for worse).
@caer your way is also interesting (and already working, so I don’t need to finish mine, haha).
I actually remembered one more benefit if this management is done inside KiCad- double-clicking a row can focus on component (just like it happens on pcbnew). This would save a mental context-switch when doing layout (especially if working on multiple monitors).
I’ve written two python scripts that read from csv file and fill the schematic fields. They are in the kicad-utils repo: https://github.com/KiCad/kicad-library-utils/tree/master/sch. Unfortunately, there is no proper documentation how to use them, but passing --help can give some hints.
Hmm, now I am trying to create a BOM I remember how time consuming it is even for a small project. So naturally I am writing yet another BOM manager
Extracting data from the Kicad files is quite easy, thanks to the convenient text format. The S-expression format is quite nice, so I look forward to eeschema getting the same treatment.
There are obviously several views on how and where to store the data, I am quite agnostic on that. I tend to use different methods depending on case, so I would try to make it flexible. However it is done, it would be really nice to have a “one click to order” button. Live pricing is also a pretty neat idea.
Getting the data could be a hard bit, given the sheer number of SKUs. I’d also look to connect up with footprints and 3d models if possible. Octopart have a good set of part data, and a “free” APi (several restrictions). Snapeda have a lot of footprint data for various tools including Kicad, with a Freemium service. $99 per month for the advanced service is out of my price range, but I might be able to make use of the basic service.
Ultimately it would be nice to have the functionality in Kicad, but I’d be fine with a standalone tool.
@Ricardo_Crudo, thanks for pointing me to your routines. The Schematic object makes it relatively easy to update a schematic from the XLSX file generated by KiCost.
This is interesting. I am the author of PartsBox.io, which is a tool that helps you keep track of your parts. I’ve been thinking about KiCad integration for a while now, as I use KiCad myself. I don’t have clearly defined goals for that integration, though. What you are describing is similar to some of my notes.
Is your goal to import additional data into KiCad, or to export a “proper BOM”?
I’ve been planning on introducing “Projects” (BOMs) into PartsBox, into which you could import KiCad data (not sure what form yet) and maintain a mapping from KiCad components to PartsBox parts. That would give you a way to export a BOM with manufacturer part numbers, datasheet links, and also distributor/sourcing information (soon, after I get around to adding that to PartsBox). However, it would not import anything into KiCad.
The other idea was to use KiCad to store mapping information, but the maintenance cost might be too high for me. I guess I could expose an API that people could use to write such plugins. But I’m not sure if this is the right way to go: I have a feeling that managing your parts inventory and choosing suppliers do not necessarily belong in KiCad itself.
Caer, wonderful work! I had to tinker with this for awhile before getting it to work; seems it will accept .tsv files with tab delimiters, but only if each entry is not enclosed in quotes. Used WinMerge to find it does some interesting things:
Blank entries ("") it replaces with ("~"), which seems like a good idea.
It won’t run if ‘Reference’ is enclosed in double quote chars. This eliminates double-quoting all fields. (Shouldn’t be an issue if using tab delimiters, but could be problematic with comma delimiters, as some part numbers do contain commas.) EDIT/
Nevermind, I entered backslashes instead of forwards-slashes. My bad! /EDIT
4, On a component with many of the other fields missing, there appears to be no order in which they are added. Or when rearranging the spreadsheet columns, the new order isn’t necessarily what happens. It would be awesome if it wrote all of the fields in the same order as the .tsv file.
This was on Win7 x64, Python 2.7.11, KiCad BZR 6425. Awesome job!
His is so weird. 2 month ago I asked for exactly a script like this (thread) and now it turns out that there are even more than one
The last month i tried to write a script for this (asks user which fields should be updated, reads the .sch, looks for #comp, searchs in .csv and replaces values/writes new)… i never done this before and the script is now 300 lines long … and now its almost useless
Download the WinPython installer for Python 2.x.x (32-bit, MUST be 2.x.x version!!! Does not play well with 3.x.x versions): https://www.python.org/downloads/
Run the installer. In addition to installing Python proper, it will also install pip and easy_install (under \Python2x\scripts) automatically.
After the install has finished, open a command window and run the command ‘easy_install kicost’ (prefered) or ‘pip install kicost’. That will install kicost and any dependencies it has (into \python2x\scripts).
Now you should be able to run kicost in a command window using the command ‘kicost -i file.xml’ or ‘python -m kicost -i file.xml’ without quotes.
If you get the message [“easy_install” or “pip” command not found], then you have to add \python2x\scripts to the path.
Currently the CLI version is stable, I’m working on a GUI version which is not complete yet.
There are a number of features which I have found lacking in both the default BOM scripts and some others I have found online. If anyone likes what I’ve done, please feel free to contribute. I have designed this to be very user-configurable (although there is only a small number of options available currently).
All efforts are well appreciated. Just make sure you consider the ‘tab’ as a separator when exporting the values. Outside the US the comma is used to separate the integer part of a number from the decimals. Weird results like 4 (next column) 7uF.
Thanks
At first I made a simple tool to manage my BOM as they were going too complex to manage them from a single spreadsheet, I recently upgraded it to be a full BOM management tool.
You can have a look on it at https://github.com/turdusmerula/kipartman.
This version is fully usable but note that it’s still under development so everything is not yet available.
You can manage a database of parts with associated footprints and maintain your BOM from this part catalog. I plan to extend it to enable a KiCost like functionality.