Edit: Changed category to Software. I’m hoping this is correct, “External Plugins” seemed wrong when I read the description.
Is there any way in Python to get the path to the active footprint library?
I’m a beginner both in Python and in Kicad/Pcbnew scripting. I’m trying to iterate over all modules on the board and listing the 3D Models associated with the footprint in the lib. Later I will update each module on the board which does not correspond with the footprint in the lib, much like the “Update Footprints from Library” function in Pcbnew.
I have written a small loop which successfully lists the 3D model, but when I use ‘FootprintLoad()’ it requires me to specify the path to the library. I would like to use the path of the active library in Pcbnew instead, but I really can’t figure out how to get this path.
pcb = pcbnew.GetBoard()
for mod in pcb.GetModules():
fpid = mod.GetFPID()
footprint = pcbnew.FootprintLoad(“C:/git/am-hardware/lib/KiCAD.pretty”, fpid.GetUniStringLibItemName())
lib_component = pcbnew.MODULE(footprint)
lib_model_list = lib_component.Models()
for lib_model in lib_model_list:
print('Lib 3D model filename: ’ + lib_model.m_Filename)