I am trying to do parser of the schematic file and I miss the list of the libraries used in the project plus the path. I see that this information is present when you generate the netlist file, but this requires a manual extra step.
Does anybody how to access to the list and paths of the libraries present in a specific project?
Each project can have its own fp-lib-table and sym-lib-table. Each user has the global tables in their configuration. The path variables which can be used in the library tables are defined in the user configuration.
So, if you have an external script you have to read some files, i.e. you need the extra steps anyways.
My idea is to create a new library (my library) with copies of the components that I first select in the official kicad library and other github libraries. Instead of adding the components manually to my new library this could be done with the scrip that analyses the components in my schematic and appends new components found to the new library (and change them in the schematic). The idea of the new library is to add more attribute to the components (like the JBLPCB code), small modifications or relate the footprint with the 3d model. The script could generate the BOM easily too.
In order for your scripts to be able to extract data from KiCad’s libraries, you first need all schematic symbols to have valid footprints assigned.
Currently about 75% of schematic symbols have pre-assigned footprints:
If you have assigned the footprints, it’s pretty easy to get those footprints into a separate library. First put them on the PCB with: Eeschema / Tools / Update PCB from Schematic [F8], and then: Pcbnew / File / Archive Footrpints / …
This does put the footprints into (new or existing) library, but does not update the links to point to that library.
You may also want to have a look at:
There are (links to) some 60+ KiCad related projects and scripts.
I’ve got a bit of a mushy mind with lots of holes. Can’t remember who forked which project from where. GIT is a bit chaotic in that aspect, but maybe one (or some) of these projects are useful for studying or modifying into your own scripts.
When you decide what to do, remember also that the schematic file format will be completely different in the upcoming v6 (hopefully early next year, 2021). Eeschema will also have a python API then. If you now write it for v5 file format you will have to rewrite it later, especially if you then want to use python and the API then instead of reading and parsing the files.