Wie man grafische Footprint-Elemente mit der KiCAD-pcbnew-Plugin-Python-API erhält

English Deutsch

Siehe unseren vorherigen Post Wie man eine Liste aller Footprints mit der KiCAD-pcbnew-Plugin-Python-API erhält und Wie man alle ausgewählten Footprints mit der KiCAD-pcbnew-Plugin-Python-API erhält für weitere Informationen darüber, wie man ein Footprint-Objekt erhält.

Sobald Sie ein pcbnew.FOOTPRINT-Objekt haben, können Sie dessen grafische Elemente (was im Wesentlichen die Linien, Rechtecke, Kreise usw. im Footprint sind - aber keine Siebdruck-Labels) mit

footprint_graphical_elements.py
footprint.GraphicalElements()

erhalten. Beispiel:

footprint_graphical_iter.py
for graphical_element in footprint.GraphicalItems():
    print(graphical_element)

Ausgabe:

output.txt
<pcbnew.FP_TEXT; proxy of <Swig Object of type 'FP_TEXT *' at 0x7fc47f2c41e0> >
<pcbnew.FP_SHAPE; proxy of <Swig Object of type 'FP_SHAPE *' at 0x7fc47f0f10b0> >
<pcbnew.FP_SHAPE; proxy of <Swig Object of type 'FP_SHAPE *' at 0x7fc47f2c69d0> >
<pcbnew.FP_SHAPE; proxy of <Swig Object of type 'FP_SHAPE *' at 0x7fc47f2c6d30> >
<pcbnew.FP_SHAPE; proxy of <Swig Object of type 'FP_SHAPE *' at 0x7fc47f0f10e0> >
<pcbnew.FP_SHAPE; proxy of <Swig Object of type 'FP_SHAPE *' at 0x7fc47f2c6cd0> >
<pcbnew.FP_SHAPE; proxy of <Swig Object of type 'FP_SHAPE *' at 0x7fc47f2c6ca0> >
<pcbnew.FP_SHAPE; proxy of <Swig Object of type 'FP_SHAPE *' at 0x7fc47f0f38d0> >
<pcbnew.FP_SHAPE; proxy of <Swig Object of type 'FP_SHAPE *' at 0x7fc47f2c68b0> >
<pcbnew.FP_SHAPE; proxy of <Swig Object of type 'FP_SHAPE *' at 0x7fc47f2c41e0> >
<pcbnew.FP_SHAPE; proxy of <Swig Object of type 'FP_SHAPE *' at 0x7fc47f0f10b0> >
<pcbnew.FP_SHAPE; proxy of <Swig Object of type 'FP_SHAPE *' at 0x7fc47f2c69d0> >
<pcbnew.FP_SHAPE; proxy of <Swig Object of type 'FP_SHAPE *' at 0x7fc47f2c6d30> >

Sie können sie mit

filter_graphical_items.py
fp_texts: list[pcbnew.FP_TEXT] = [
    item for footprint in selected_footprint.GraphicalItems()
    if type(item).__name__ == 'FP_TEXT'
]
fp_shapes: list[pcbnew.FP_SHAPE] = [
    item for footprint in selected_footprint.GraphicalItems()
    if type(item).__name__ == 'FP_SHAPE'
]

filtern.


Check out similar posts by category: Electronics, KiCad