kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #34925
Need guidance/hints on accessing list of available pcbnew footprints from python
In one of my python plugins, I want to know the list of available
footprints (mounting holes, in this case)
Digging through the code, I can't make heads or tails of how to get this
information. There are a bunch of abstract class involved. impls....
There are a couple possibilities, none of which seem clean.
*Stuff from FOOTPRINT plugin*
looking in footprint.i, I see some APIs that are close.
If I have a directory path to a fp library, I can
call pcbnew.FootprintEnumerate for a nice list.
but for that, I first have to have a list of fp library paths. *How do I
get such a list? *This seems like the closest answer. I see my config dir
has a fp-lib-table file which would be easy to parse. But that's a hack.
*FOOTPRINT_LIST_IMPL possibility*
looking in load_select_footprint, I see it has a static FOOTPRINT_LIST_IMPL
which does have the APIs I'd need to get to a nice list of footprint_infos.
But it's static to that file. I could copy the relevant code to
python_scripting_helpers. but that feels messy.
PCB_BASE_FRAME does have a method for popping up a table for a user to
choose a footprint, which is nice for UI. It could even be useful for
python plugins with some GUI stuff. But many python scripts will just want
a list of libraries and modules.
*PROJECT possibility*
I tried exposing PROJECT to python as it has a number of useful sounding
API including PcbFootprintLibs which returns a FP_LIB_TABLE. By poking
around in gdb, I see that FP_LIB_TABLE has GetCount and IsEmpty. IsEmpty
returns false if I set includefallback to true. and the fallback list does
indeed have stuff in it. But it's protected and I don't see how to get to
it.
Can I expose the fallback table via a public get method?
Is that a path that has any hope?
*So what's the most straight forward way to get to the list of libraries
and modules within them?*
Thanks
Miles
Follow ups