Deleting tracks via python plugin

I am trying to clean the PCB at the beginning of my python plugin by deleting all tracks.
When I do:

for track in GetBoard().GetTracks():
     track.DeleteStructure()

KiCAD works for a couple of seconds and then just crashes without any messages. I also tried

for i in range(len(board.GetTracks())):
        board.GetTracks()[-1].DeleteStructure()

and got the same result.

Running it from the KiPython console seems fine, however.

Can anyone tell me why this is happening?
I am using 6.0.0 on linux mint.

Can you give us more details on which version of Kicad you are using? I’m not really familiar with Python or using it in Kicad, but knowing which version you’re using will let people help you more quickly.

Goto Help → About KiCad and paste that info into a reply. Also, do you have a small test PCB that you could post as well which shows this problem? Or post the PCB itself if it’s not anything secret? You might have found a bug…

John

Sure, thanks for the reply.
I actually found that the demo scripts can lead to a crash too. I opened an issue on GitLab:

and it seems like there are even fixes committed now. Pretty cool.
I still need to try them, however.

Application: KiCad

Version: 6.0.0-d3dd2cf0fa~116~ubuntu20.04.1, release build

Libraries:
wxWidgets 3.0.4
libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3

Platform: Linux 5.4.0-91-generic x86_64, 64 bit, Little endian, wxGTK, cinnamon, x11

Build Info:
Date: Dec 23 2021 14:23:02
wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24
Boost: 1.71.0
OCC: 7.5.2
Curl: 7.68.0
ngspice: 31
Compiler: GCC 9.3.0 with C++ ABI 1013

Build settings:
KICAD_USE_OCC=ON
KICAD_SPICE=ON

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.