Replicate layout: Action plugin

The first one is a wild one, and it would require significant changes to the existent code as I check/calculate only square bounding boxes. I’d have to check each polygon corner position (for footprint courtyards and zones). Doable, but difficult. Coupled with the fact that UI would be awkward at best, the feature would be hardly used and it would significantly increase the maintenance effort and bug likelihood. So if I finish with ever other idea I have, I’ll start with this one (read as: most likely never).

As a workaround for the duplicate tracks, just run the plugin again with delete tracks option selected. Come to think of it, I should probably check this option by default.

I tried to include the Action Plugins on my Ubuntu system but some of them were completely missing (like the replicate layout plugin) were not loaded at all and others like the swap_pins plugin generated errors like

action_swap_pins.py"line 50, in Run )[0]

TypeError: ‘filter’ object is not subscriptable

has anyone which causes this error and was anyone able to get the script running on Ubuntu systems?

Best regards.

kicad version:

Application: kicad
Version: 5.1.0-060a0da~80~ubuntu18.04.1, release build
Libraries:
wxWidgets 3.0.4
libcurl/7.58.0 OpenSSL/1.1.0g zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1 (+libidn2/2.0.4) nghttp2/1.30.0 librtmp/2.3
Platform: Linux 4.15.0-46-generic x86_64, 64 bit, Little endian, wxGTK
Build Info:
wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.22
Boost: 1.65.1
OpenCASCADE Community Edition: 6.9.1
Curl: 7.58.0
Compiler: GCC 7.3.0 with C++ ABI 1011
Build settings:
USE_WX_GRAPHICS_CONTEXT=OFF
USE_WX_OVERLAY=ON
KICAD_SCRIPTING=ON
KICAD_SCRIPTING_MODULES=ON
KICAD_SCRIPTING_PYTHON3=ON
KICAD_SCRIPTING_WXPYTHON=ON
KICAD_SCRIPTING_WXPYTHON_PHOENIX=ON
KICAD_SCRIPTING_ACTION_MENU=ON
BUILD_GITHUB_PLUGIN=ON
KICAD_USE_OCE=ON
KICAD_USE_OCC=OFF
KICAD_SPICE=ON

ubuntu 18.04.2

Be more specific, give your Ubuntu version and also KiCad version. For the latter open Help->About KiCad and click Copy Version Information and paste it here.

you’re absolutely right, i added the info in my posts above.

The first suspect that comes to mind is python3, as my plugins were tested only with python2. Could you please look into the project folder for any log files and send them to me. It would be even better if you raised an issue on github

I’m looking forward to the day Python 2 will finally be obsoleted.
According to Wikipedia its obsolete since 2015:

Python 2.7’s end-of-life date was initially set at 2015 then postponed to 2020 out of concern that a large body of existing code could not easily be forward-ported to Python 3.
Source:
https://en.wikipedia.org/wiki/Python_(programming_language)

Python 2 seems to be finally end of lifed by 2020, which is a problem for KiCad because it still seems to be dependent on Wx_bla_bla libs in Python 2 on windoze? See this trhead from earlier today:

https://forum.kicad.info/t/why-is-python-version-shown-as-2-7-in-kicad5-1-0/15874/7

There are ongoing efforts to motivate projects to move on to Python V3:
https://python3statement.org/

It’s not so slow as the metrification of the world. One particular country is still using some other weird units despite repeated attempts to switch to metric. This has been going on since about 1875, and about 100 years later it was unfortunately only “recommended” to switch to metric. None the less, the’re slowly switching, but very slowly. In the meantime here in Europe we get increasinly confronted with weird units in supermarkets and crashing probes on distant planets. Sigh.

Yup, I can confirm it is a python3 issue. And I have the same code in all my plugins.

This was just fixed, but has not been tested as I don’t have a python3 build available.

There a still some likely bugsof the same sort (in python3 filter returns an iterable instead of list as python2 does) lurking in the code. I’ll try to address them as quick as I can.

EDIT: these have been fixed

The change in how division is handled can also trip you up. But mostly when going from python 3 down to python 2. (Might still be something where you need to invest time when making your project run equally well for both python 2 and python 3. In general the future package should give you an easy way to have your stuff compatible with both.)

Yeah I’ve handled the division some time ago, when there was a python3 release for windows available. And since then I am using the future package.

I’ll probably ping the person responsible if he can release 5.1 also.

I tried the fixes and additional issues came up. I opened a github ticket because its probably better to track the issues there. If you need someone to test the fixes, feel free to call me.

@orsonmmz used this as an example in his KiCon 2019 talk :slight_smile: https://youtu.be/_zVJ96SdYrs?t=1398

2 Likes

Thanks for the notice. It’s always nice to be noticed.

It is a great plugin, definitely deserves some publicity. Thanks @MitjaN !

1 Like

Thanks, and while I have your attention there are two things I’d like to point out:

  1. Is there any plan to include any of the plugins to the KiCad package?
  2. I thought I’d let you know that there were at least two attempts at central plugin repository:

It is something to keep in mind when planing a roadmap for KiCad’s python funcitionality

I would rather simplify the plugin installation process and let the users decide which plugins they want to have.

2 Likes

One idea would be to imitate FreeCAD’s plugin/script manager where the user can install a new Plugin with a couple of clicks from a central repository, but still is able to install Plugins the “hard way” putting the files on the correct path. The manager could also check which plugins are compatible with the current version of KiCAD, in order to not show broken/unmanteined/old stuff.

3 Likes

(This discussion could be moved out of this thread)
We should first check with the developer the better way to do it:

  1. A code included in the KiCad;
  2. A python plugin default installed at KiCad (that could also autoupdate).

In https://bugs.launchpad.net/kicad/+bug/1823733 I propose the creation of a https://github.com/KiCad/plugins repository to keep just the meta data and the plugin will check the installed version and the avaliable to download (the important infos will be: name, description/propose, category, icon, version, download link and we could reserve some info to say “pcbnew plugin” for allow future “eeschema plugins” https://bugs.launchpad.net/kicad/+bug/1728258).

I didn’t check kipi yet but, even if by a hard way (not using git commands) it will be interesting deal with different branch and repositories (I usually keep ‘stable’ and ‘in-development’ at git, should be interesting give this options to the users, also because I need some users to check my in-development version).

1 Like

Another open source project to borrow (steal) ideas from is the ArduinoIDE board manager. That system allows pointing to several repositories that each maintain their own repository manifests. Allowing to install plugins (for different board targets) not only from the “official” source, but also 3rd party locations (I have attiny, AdaFruit, and SparkFun linked). I’m not saying that the ArduinoIDE board manager doesn’t have it’s own problems, but there is certainly some techniques worth learning from there.

1 Like

I also like this Arduino IDE feature (although other aspects of the software are rather more dubious). One especially useful aspect is that it allows you to select exactly which version you want to install very easily.