I’m working on a plugin to make it easier to build a panelized PCB, since I don’t see anything else available for recent KiCad versions other than the “Append Board” feature. I did find an older “panelize.py” script out there, but it does not appear to be applicable to the current PCB file format. Besides being very manual, the “Append Board” feature has one issue that’s causing trouble for me: I want my panel to include rotated instances of the board I’m panelizing, but the orientations of reference designators change on the rotated boards because reference designators are automatically forced to appear in one of two orientations. In my plugin, I plan to automatically set reference designators invisible and replaced them with static silkscreen text, such that all panelized boards will be identical after rotation.
The model I’m currently working on involves importing a plugin and then using the plugin’s classes and functions to load one or more boards to be panelized, then instantiate one or more copies in the currently-loaded board as returned by pcbnew.GetBoard(). I’m making some early progress despite limited documentation, using a lot of trial and error. I’m presently able to read in a board from an external file and then add multiple partial copies of it at desired locations in the currently-loaded board. I have a ways to go yet, but I’d like to ask for some help with a couple issues that I haven’t been able to figure out myself yet, and I’m hoping that there’s a pcbnew Python plugin expert out there who can help me.
First, adding my board instances to the loaded board file doesn’t update the screen. I need to click the redraw button or perform some other action to redraw the screen, such as the zoom all function, to get the added board instances to show up on the screen. Is there a programmatic way to force a screen redraw from within a Python based pcbnew plugin?
Second, after I add my board instances, the “save” button doesn’t get un-grayed and enabled. I can set the modified flag with pcbnew.GetBoard().SetModified(), but doing so doesn’t enable the save button in the toolbar. Redrawing the screen after setting the modified flag doesn’t enable the save button, either. Can anybody help me figure out how to get pcbnew to accept that the loaded board has been changed?
If all else fails, I could probably change my model to save the panelized board to a new file rather than modifying the loaded board in pcbnew. But I’d rather not do that, because I think it would be clumsier and less flexible vs. allowing the user to interactively panelize in the loaded board (which may already contain stuff to be included in the panel) from the scripting console.
In case it matters, I’m currently developing this script under OSX with version 2014-16-16 BZR 5324. I’m also trying to build newer KiCad versions on my Mac, but I haven’t succeeded yet. I have some problems with the nightlies, and the Mac building instructions aren’t working for me; both probably because I’m running 10.10 (Yosemite) and the nightlies and build instructions appear to be for an older OSX version, prior to some compiler and library changes that broke a bunch of stuff. I’ll move my development and testing to a more recent version once I get one working well on my Mac.