Ao usar a API Python do KiCAD para pcbnew, você pode obter uma lista de objetos FOOTPRINT usando
get_footprints.py
board: pcbnew.BOARD = pcbnew.GetBoard()
footprints: list[pcbnew.FOOTPRINT] = board.GetFootprints()O : pcbnew.BOARD e : list[pcbnew.FOOTPRINT] são opcionais mas dirão ao seu editor (como o Visual Studio Code) qual objeto esperar para melhor autocompletar.
Exemplo 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 # Opcional, padrão é False
self.icon_file_name = os.path.join(os.path.dirname(__file__), 'simple_plugin.png') # Opcional, padrão é ""
def Run(self):
board: pcbnew.BOARD = pcbnew.GetBoard()
footprints: list[pcbnew.FOOTPRINT] = board.GetFootprints()
# TODO Faça algo útil com [board]
for footprint in footprints:
print(footprint)
SimplePlugin().register() # Instanciar e registrar no Pcbnew
Check out similar posts by category:
Eletrônica KiCad
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow