I want to copy a footprint from one board to a other with python, to make a panel. I read in a forum post [1] i should use <source board>.GetModules(), pcbnew.MODULE(<module>) and <target board>.Add(<copy>). However, this only works when source and the target board is the same. I get a segment fault if i do it from one board to a other*. Is there a other way to do this which is the correct way or is this way already correct and a bug in the KiCAD python library**?
I attached a zip-file [2] which includes a project and a python script, create_panel.py, which returns in a segment fault.
The trick is to remove it from the source board, and only then to place it in the target panel.
Workflow: Load a board, for each item remove it from the source board and then add it to the target panel. Repeat for each board, if you need two copies of the same source board, reload the source board from disk.
Edit: as far as I remember I had a working method to copy modules but the Python interface changed, so I decided for a simpler more robust method.
Another perhaps more productive question: you are copying the nets too I hope? I tried removing that and I get a segfault too if I ignore the nets. It seems these do not need to be removed, I simply use
for net in list(source.board.GetNetsByName().values()):
self.board.Add(net)