Al usar KiCAD’s Python API para pcbnew, puedes obtain un list de FOOTPRINTobjects usando
get_footprints.py
board: pcbnew.BOARD = pcbnew.GetBoard()
footprints: list[pcbnew.FOOTPRINT] = board.GetFootprints()El : pcbnew.BOARD y : list[pcbnew.FOOTPRINT] son optional pero tellaran a tu editor (tal como visual studio code) cual object to expect para better autocompletion.
Ejemplo completo de plugin:
simple_plugin.py
#!/usr/bin/env python
import pcbnew
import os
class SimplePlugin(pcbnew.ActionPlugin):
def defaults(self):
self.name = "Plugin Name as shown in Pcbnew: Tools->External Plugins"
self.category = "A descriptive category name"
self.description = "A description of the plugin and what it does"
self.show_toolbar_button = False # Optional, defaults a False
self.icon_file_name = os.path.join(os.path.dirname(__file__), 'simple_plugin.png') # Optional, defaults to ""
def Run(self):
board: pcbnew.BOARD = pcbnew.GetBoard()
footprints: list[pcbnew.FOOTPRINT] = board.GetFootprints()
# TODO Do something useful con [board]
for footprint in footprints:
print(footprint)
SimplePlugin().register() # Instantiate y register a Pcbnew
Echa un vistazo a artículos similares por categoría:
Electrónica KiCad
Si este artículo te ha ayudado, considera invitarme a un café o hacer una donación vía PayPal para apoyar la investigación y publicación de nuevos artículos en TechOverflow