kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #34928
Re: Need guidance/hints on accessing list of available pcbnew footprints from python
-
To:
<kicad-developers@xxxxxxxxxxxxxxxxxxx>
-
From:
Maciej Sumiński <maciej.suminski@xxxxxxx>
-
Date:
Tue, 13 Mar 2018 12:15:50 +0100
-
Authentication-results:
spf=pass (sender IP is 188.184.36.46) smtp.mailfrom=cern.ch; lists.launchpad.net; dkim=none (message not signed) header.d=none;lists.launchpad.net; dmarc=bestguesspass action=none header.from=cern.ch;
-
In-reply-to:
<CAH3vBST-cs3+7YGvqCG33cC4ZHrgiD3FbnBqFVkG=rBkXKoS0g@mail.gmail.com>
-
Spamdiagnosticmetadata:
NSPM
-
Spamdiagnosticoutput:
1:99
-
User-agent:
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2
Hi Miles,
Have you seen FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList()
(pcbnew/footprint_viewer_frame.cpp)? It might be the easiest way to go.
Perhaps it could be wrapped in a function provided by the scripting
interface.
I could not find 'includefallback' option you have mentioned, would you
point me to the relevant source code?
Regards,
Orson
On 03/13/2018 10:49 AM, miles mccoo wrote:
> 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
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help : https://help.launchpad.net/ListHelp
>
Attachment:
signature.asc
Description: OpenPGP digital signature
Follow ups
References