Wie man eine KiCAD-Pick&Place-Positionsdatei mit pandas in Python liest
English
Deutsch
Wenn Sie eine KiCAD-Pick-&-Place-Positionsdatei exportiert haben über die GUI oder die Kommandozeile:
kicad_export_pos_to_file.sh
kicad-cli pcb export pos MyPCB.kicad_pcb --units mm -o MyPCB.poskönnen Sie sie aus Ihrem Python-Skript mit pandas.read_table(...) wie folgt lesen:
read_pos_with_pandas.py
import pandas as pd
pos = pd.read_table('KKS-Microcontroller-Board-R2.2.pos', delim_whitespace=True, names=["Ref", "Val", "Package", "PosX", "PosY", "Rot","Side"], comment="#")Optional können Sie pos auch nach der Ref-Spalte indizieren (die Werte wie C12, D1 oder U5 enthält):
set_index_example.py
pos.set_index("Ref", inplace=True)Sie können all das auch in eine Funktion packen:
read_kicad_pos_file.py
def read_kicad_pos_file(filename):
pos = pd.read_table(filename, delim_whitespace=True, names=["Ref", "Val", "Package", "PosX", "PosY", "Rot","Side"], comment="#")
pos.set_index("Ref", inplace=True)
return posWenn Sie .set_index() verwendet haben, können Sie auf eine Komponente wie C13 zugreifen mit
example_lookup.txt
pos.loc["C13"]Beispielausgabe:
example_output.txt
Val 100nF_25V
Package C_0603_1608Metric
PosX 187.1472
PosY -101.8243
Rot 180.0
Side top
Name: C1, dtype: objectIf this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow