How to delete everything on PCB board in python?

I have written a python script to generate a board containing a variable number of submodules in a grid. It works just fine.

However, I would like to automatically delete the previously generated version. That is, I am trying to iteratively create a size X board, then a size X+n board, and so on. However, I can’t figure out how to delete everything on the size X board before proceeding to the size X+n board.

I thought that

pcbnew.GetBoard().ClearProject()

seemed like what I wanted but once I do pcbnew.Refresh() kicad just crashes. Can anyone clue me in on the correct way to do this?

Thanks much!

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