How to unload board from Python bindings

I would like to load a pcb in pcbnew, do some stuff, exit, load another, repeat.

At the loading of the third pcb, kicad crashes. Which I can imagine, because I did not unload anything.

How can I unload a pcb, after loading it with pcbnew.LoadBoard(fileName)?

Thanks in advance!

Usually you don’t have to explicitly unload anything. In python once a variable goes out of scope and there are no references to it, it gets garbage collected and swig will clean up c++ objects behind them too.

There may be some bugs or rather things that are not deterministic in terms of order of destruction so you can manually del all variables that you want to clean up and control the order that way. So clean up any board derived objects (netlist, footprints, etc) first and then delete the board.

But chances are that your crash is because of something else, try to narrow that down first.

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