AngusE
AngusE

Reputation: 1

How to read KiCad page settings values from a python BOM generation script

I am using KiCad V6 and have modified the bill of materials generation script bom_csv_grouped_by_value.py to produce BOM's only containing the information I am interested in, and formatted how I like. These currently have the filename matching the KiCad project name, e.g. for a project called "valve-tester" it would be valve-tester.xlsx. I would like to be able to read the "Title" and "Revision" fields from the schematic Page Settings to name the BOM something more meaningful, e.g. BOM for Valve Tester revC 17-11-22.xlsx.

"Title" and "Revision" fields

Does anyone know how I can extract this information from a python script, or somehow automate passing it in as an argument? Any help would be greatly appreciated!

So far I am thinking one option would be to have the user manually enter the desired filename each time you run the script, although this is sub-optimal and I am aiming to automate it.

Upvotes: 0

Views: 170

Answers (1)

AngusE
AngusE

Reputation: 1

Turns out you can just read the .kicad_sch schematic file as a text file and the information is all there, e.g

with open ("valve-tester.kicad_sch", "r") as myfile:
    data = myfile.read().splitlines()
    title_line = data[7]
    revision_line = data[9]

Upvotes: 0

Related Questions