How to get footprint wizards to show up?

Asked by Kalle Hyvönen

I made a custom footprint wizard script in python but I cannot get it to show up in the footprint wizard. From what I can gather putting the script in ~/.kicad_plugins should make it show up but even if I put the supplied example there it does not show up. The script files have exec rights. What do I need to do to make the footprint wizard find my python scripts? I'm using KiCAD 2012-08-23 BZR 3679.

Question information

Language:
English Edit question
Status:
Solved
For:
KiCad Edit question
Assignee:
No assignee Edit question
Solved by:
Kalle Hyvönen
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
Dick Hollenbeck (dickelbeck) said :
#1

On 08/29/2012 10:55 AM, Kalle Hyvönen wrote:
> New question #207186 on KiCad:
> https://answers.launchpad.net/kicad/+question/207186
>
> I made a custom footprint wizard script in python but I cannot get it to show up in the footprint wizard. From what I can gather putting the script in ~/.kicad_plugins should make it show up but even if I put the supplied example there it does not show up. The script files have exec rights. What do I need to do to make the footprint wizard find my python scripts? I'm using KiCAD 2012-08-23 BZR 3679.
>

Starting from the most obvious:

a) Pcbnew must be compiled with scripting enabled, and that is not the default. This
means you must build it yourself.

b) I think Miguel searches for scripts based on an environment variable.

c) Consult the source.

d) step through with debugger. It rarely lies.

Revision history for this message
Kalle Hyvönen (scorper) said :
#2

Well thanks, that helped! Did not assume it was not compiled since the footprint wizard button and system are there (which kind of makes no sense). Googling returned pretty much zero amount of information about the whole feature. I'll write some kind of a tutorial once I get the hang of it.

Debugging the scripts seems pretty awful though, since you cannot run the scripts by themselves and print does not print anything to the terminal.

Revision history for this message
Lorenzo Marcantonio (l-marcantonio) said :
#3

On Thu, Aug 30, 2012 at 12:26:01PM -0000, Kalle Hyvönen wrote:
> Debugging the scripts seems pretty awful though, since you cannot run
> the scripts by themselves and print does not print anything to the
> terminal.

Have you tried with execfile in the python console?

--
Lorenzo Marcantonio
Logos Srl

Revision history for this message
Dick Hollenbeck (dickelbeck) said :
#4

On 08/30/2012 07:26 AM, Kalle Hyvönen wrote:
> Question #207186 on KiCad changed:
> https://answers.launchpad.net/kicad/+question/207186
>
> Status: Answered => Solved
>
> Kalle Hyvönen confirmed that the question is solved:
> Well thanks, that helped! Did not assume it was not compiled since the
> footprint wizard button and system are there (which kind of makes no
> sense). Googling returned pretty much zero amount of information about
> the whole feature. I'll write some kind of a tutorial once I get the
> hang of it.
>
> Debugging the scripts seems pretty awful though, since you cannot run
> the scripts by themselves and print does not print anything to the
> terminal.

If you run Pcbnew from the command line, rather than under kicad project manager, see if
that makes re: terminal output.

Revision history for this message
Kalle Hyvönen (scorper) said :
#5

Running pcbnew from the command line seems to work, which makes debugging way easier!

Any handy way to make pcbnew reload the scripts other than restarting pcbnew?

Revision history for this message
Kalle Hyvönen (scorper) said :
#6

Whoops accidentally reopened.

Revision history for this message
Dick Hollenbeck (dickelbeck) said :
#7

On 08/31/2012 12:11 AM, Kalle Hyvönen wrote:
> Question #207186 on KiCad changed:
> https://answers.launchpad.net/kicad/+question/207186
>
> Status: Solved => Open
>
> Kalle Hyvönen is still having a problem:
> Running pcbnew from the command line seems to work, which makes
> debugging way easier!

Great. Hopefully your scripts operate in a way that is compatible with the nanometer build.
I think we are nearing a point where that will be standard soon.

>
> Any handy way to make pcbnew reload the scripts other than restarting
> pcbnew?

Miguel could probably add this in 20 minutes if its not in there. You want it tied to a
button or menu?

Revision history for this message
Dick Hollenbeck (dickelbeck) said :
#8

On 08/31/2012 12:11 AM, Kalle Hyvönen wrote:
> Question #207186 on KiCad changed:
> https://answers.launchpad.net/kicad/+question/207186
>
> Status: Solved => Open
>
> Kalle Hyvönen is still having a problem:
> Running pcbnew from the command line seems to work, which makes
> debugging way easier!
>
> Any handy way to make pcbnew reload the scripts other than restarting
> pcbnew?
>

Is this the kind of thing that is practical using the scripting?

This is quite excellent work here:

   http://kicad.rohrbacher.net/quickmod.php

A script version of something like this might make it easier to "obtain" the product
module directly into pcbnew.

Revision history for this message
Dick Hollenbeck (dickelbeck) said :
#9

It should also be said that the product should be a MODULE instance, not a file.
Maybe this was obvious, but file formats are changing.

Revision history for this message
Kalle Hyvönen (scorper) said :
#10

That quick-mod gen looks pretty handy! Maybe not for every module but it would cover a lot of packages.

Any precautions about the nanometer change I should know about? I have so far used wxPointMM() and wxSize() for sizes.

Is EDGE_MODULE used for creating silkscreen features? The included fpc_footprint_wizard.py APPARENTLY uses it for silkscreen features (if I'm interpreting the script correctly) but it does not seem to work (no silkscreen features appear and no errors in terminal).

As for reloading the scripts I think the most logical point of doing that would be when the "Select footprint wizard" dialog opens so the scripts would be reloaded everytime the list pops up.

Revision history for this message
Kalle Hyvönen (scorper) said :
#11

Actually the EDGE_MODULE seems to work for creating silkscreens but the module viewer OR the footprint wizard window do not seem to display them. Once I import the module to pcbnew the silkscreen is visible. Cannot seem to find any visibility settings in module viewer either. Bug?

Revision history for this message
Dick Hollenbeck (dickelbeck) said :
#12

On 09/01/2012 09:51 AM, Kalle Hyvönen wrote:
> Question #207186 on KiCad changed:
> https://answers.launchpad.net/kicad/+question/207186
>
> Kalle Hyvönen posted a new comment:
> Actually the EDGE_MODULE seems to work for creating silkscreens but the
> module viewer OR the footprint wizard window do not seem to display
> them. Once I import the module to pcbnew the silkscreen is visible.
> Cannot seem to find any visibility settings in module viewer either.
> Bug?

Could it be a layer mismatch?

Revision history for this message
Kalle Hyvönen (scorper) said :
#13

I'm using the EDGE_LAYER for silkscreens. In pcbnew it is assigned to SilkS_Front layer so I'd assume it is the correct layer.

Revision history for this message
Lorenzo Marcantonio (l-marcantonio) said :
#14

Please be careful...

EDGE_LAYER is the layer mask, the layer number is EDGE_N

Also EDGE is the PCB milling border, for silk you should SILKSCREEN_N_FRONT or SILKSCREEN_FRONT (depending if you need the number or mask)

Look in include/layers_id_colors_and_visibility.h for reference (the
order is the same as in the UI)

(I think we are hitting the 'unchecked parameter' issue we talked about in
a previous scripting thread...)

Revision history for this message
Kalle Hyvönen (scorper) said :
#15

Ok, I was just following the supplied fpc-connector wizard which uses the
EDGE_LAYER. Is it intended that pcbnew shows it as SilkS_Front?

On Sun, Sep 2, 2012 at 10:41 AM, Lorenzo Marcantonio <
<email address hidden>> wrote:

> Your question #207186 on KiCad changed:
> https://answers.launchpad.net/kicad/+question/207186
>
> Lorenzo Marcantonio posted a new comment:
> Please be careful...
>
> EDGE_LAYER is the layer mask, the layer number is EDGE_N
>
> Also EDGE is the PCB milling border, for silk you should
> SILKSCREEN_N_FRONT or SILKSCREEN_FRONT (depending if you need the number
> or mask)
>
> Look in include/layers_id_colors_and_visibility.h for reference (the
> order is the same as in the UI)
>
> (I think we are hitting the 'unchecked parameter' issue we talked about in
> a previous scripting thread...)
>
> --
> You received this question notification because you asked the question.
>

Revision history for this message
Lorenzo Marcantonio (l-marcantonio) said :
#16

It's not intended, it's a sanity check in the legacy loader silently kicking in!

If you look in the DS record in the generated file you'll see a huge number for the layer. The plugin simply maps invalid layer numbers to 21 (i.e. SILKSCREEN_N_FRONT) when loading module edges.

In short, the FPC40 script is wrong:P you have to use the _N_ layer constants most of the time.

Revision history for this message
Dick Hollenbeck (dickelbeck) said :
#17

On 09/01/2012 08:50 AM, Kalle Hyvönen wrote:
> Question #207186 on KiCad changed:
> https://answers.launchpad.net/kicad/+question/207186
>
> Kalle Hyvönen posted a new comment:
> That quick-mod gen looks pretty handy! Maybe not for every module but it
> would cover a lot of packages.
>
> Any precautions about the nanometer change I should know about? I have
> so far used wxPointMM() and wxSize() for sizes.

You are ahead of me on this, so I don't know. Miguel will know. Recently I decided to
simply use the nanometer build for all my work. I was seeing inaccuracies when converting
from MM to deci-mils, something that happens when using the EAGLE_PLUGIN. When I switched
to nanometer build, these "rounding errors" went away.

Might be prudent to at least try your work with nanometer build, if not outright switching
to it.

Revision history for this message
Lorenzo Marcantonio (l-marcantonio) said :
#18

On Tue, Sep 04, 2012 at 04:05:59PM -0000, Dick Hollenbeck wrote:
> Might be prudent to at least try your work with nanometer build, if not outright switching
> to it.

It *should* work either way but I think that the nano build is
substantially ready for production work (2 boards done, no issues).

Of course you lose compatibility with decimil releases

--
Lorenzo Marcantonio
Logos Srl