Script to list/edit all the parts in symbols library

Hi,

I’m cleaning up and re-organizing my entire symbols library to make it more consistent and easily maintainable. I’m also considering adding internal part numbers to use with a PLM. So I’m wondering if there are existing scripts to list and edit the data in bulk in the symbols library?

Most if the data collection needs to happen manually but it’s so tedious that I’d like to automate as much as the process as possible.

Thanks!
Fabien

The KiFields tool may do what you need, I haven’t tried it since 5.99 though.

https://devbisme.github.io/KiField/docs/_build/singlehtml/index.html#document-readme

Great! that looks like it’ll do the job. I’ll start digging.
Thank you

KiCad’s libraries are readable text, and some bulk-edits are easily done with a humble text editor and search & replace.

In KiCad V6, the library format also changed to S-expressions, so scripts for older versions do not work until they are updated for KiCad V6.

S-expressions are standardized, so there probably is a library available for your favorite scripting language.

Nice! It seems to support V6 files

0.1.18 (2021-06-28)

  • KiCad V6 schematic and library files are now supported (well, V5.99 actually, but the file formats shouldn’t change).

Even though it hasn’t received any love since Jul 28, 2021.

1 Like

Wonderful, I hope it is helpful! To me it is a hidden treasure of the KiCad ecosystem and I use it constantly on larger designs.

I haven’t had any issues with it recently, but historically the developer was very quick to help when I did have issues. Not a promise, just a point in favor of use-ability.

2 Likes

Thank you for your answers, I ended up using kifield. It’s a great tool, I only wished there was a python API.

It’d be great to make the process more automatic for some tasks without having to go through a spreadsheet, which can be tedious with a lot of parts.

I believe Python API for schematics is being worked on for v7.
I hope it will provide API for symbol libraries as well/

Can you give more details on what tasks could be more automated?

Python has never been a favorite of mine but, recently I forced myself to improve my Python skills/knowledge and I’ve been dialing-into using wxFormBuilder and wxGlade.

That said, and looking for opportunities to use the tools (and seeing this post) I quickly built a Python App to list the contents of a selected Dir. Too simple that it’s embarresing.

I packaged the App using PyInstaller (using an App I made to make PyInstaller easy to use). [FYI NOTE: PyInstaller and pyinstaller are NOT the same App’s].

Then, I made a Plugin for Kicad to run my Content_Lister App.

FormBuilder is full-featured but lacks the Cell selection feature in Glade (which has far fewer features).
I built the Apps with FormBuilder, which places the GUI details in a separate file from the User’s code file (thus, making it cleaner).

GIF video of usage and screenshot of the User code (if you want to tackle building your own plugin, you can do some homework to learn how and there’s only two lines of code to get the listing and display it)

ContLister

1 Like

devbisme
Can you give more details on what tasks could be more automated?

Currently, I’m working on organizing my parts library and adding an internal part number system to facilitate BOM generation and production in house. So I wanted to automate as much of the process as possible. That was also a good occasion learn some new skills.

BlackCoffee

Python has never been a favorite of mine but, recently I forced myself to improve my Python skills/knowledge and I’ve been dialing-into using wxFormBuilder and wxGlade.
[…]
GIF video of usage and screenshot of the User code (if you want to tackle building your own plugin, you can do some homework to learn how and there’s only two lines of code to get the listing and display it)

Thanks, that looks great! For now I made a script that parses my library files and extract them into CSV files with kifield. I edit them and insert my changes back into the files.

cioma

I believe Python API for schematics is being worked on for v7.
I hope it will provide API for symbol libraries as well/

That’d be great!

So would you rather be able to do this processing atomically on the library and eliminate the intermediate step of dumping it to a CSV file?

This time I’ll edit the CSV files by hand, but I will keep building on the what I already have and develop my tools over time. For now, I just need to get it done I think.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.