Wie man ein KiCAD-XML-BOM mit Python liest
Dieses Skript liest ein XML-BOM (auch python-bom in kicad-cli genannt) mit beautifulsoup4 und generiert als Anwendungsbeispiel ein RefDes-zu-Footprint-Name-Wörterbuch:
read_kicad_bom.py
from bs4 import BeautifulSoup
def extract_footprints_by_ref_from_xml(filename):
footprints_by_ref = {} # e.g. "C3" => "Capacitor_SMD:C_0603_1608Metric"
with open(filename, "r") as infile:
soup = BeautifulSoup(infile, features="xml")
for component in soup.export.components.findChildren("comp"):
refdes = component.attrs["ref"]
footprints_by_ref[refdes] = component.footprint.text
return footprints_by_refIf this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow