I’ve just posted a feature request to the Gitlab repo but I’m interested if anyone here maybe has novel solutions (or also would appreciate the feature).
Problem Description
The current implementation of importing a Specctra Session to a board in pcbnew requires an active window of pcbnew. This removes the ability to have a headless scripting a process of: pcbnew exports Specctra DSN, auto-route board + export Specctra session file, pcbnew imports Specctra session file and saves board.
Problem Details
I’m approaching this from the perspective of the python swig interface that exposes the pcbnew.ImportSpecctraSES
but the major changes that would need to be made are in the specctra import cpp source. My hope would be that the import could be abstracted to take a BOARD type input and then directly add the imported elements to that object. From the perspective of the python interface, it might end up looking something like the python shell snippet below.
Python 3.10.10 (main, Feb 8 2023, 14:50:01) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pcbnew
>>> board = pcbnew.LoadBoard("./my_kicad_pcb.kicad_pcb")
>>> pcbnew.newImportSpecctraSES(board, "./my_specctra_file.ses")
As a little more background, I am in the process of trying to make scripts to completely automatically generate very simple custom PCBs. My current workaround is to use an xvfbWrapper contextmanager to open the target board file with the GUI, import the SES file and then save the output (the same strategy that a lot of KiCad automation scripts have implemented). It does work but it’s extremely brittle.
Side note: I’m not sure on the etiquette/usefulness of cross posting this as both a feature request and discussion topic here. Someone please feel free to advise me if you think there’s a better approach to my posts.