I want to automate a task in KiCAD that I have to do repeatedly.
To do this I wanted to write a bash script in the (Linux) terminal that can do these steps.
It shoulf basically take a .kicad_pcb file generated by different software and parse it to an autorouter (I’m using freerouting from GitHub) and then convert it into a Gerber file for manufacturing. Turning it back into a .kicad_pcb file would be fine as well.
What I have tried so far:
There is an option in KiCAD: File > Export > Specctra DSN
This works perfectly fine but can’t be automated.
I tried to find Macros (key combinations) but couldn’t find any.
Afterwards I looked for a conversion software, but there doesn’t seem to be any software that converts from .kicad_pcb to .dsn. Not even with steps in between like: .kicad_pcb > .brd > .dsn.
Then I found out about python-scripts inside of KiCAD but it seems as if you can only start those from inside KiCAD manually.
The next idea was to look into the source code of KiCAD. One thing I found was the function:
bool ExportSpecctraFile( const wxString& aFullFilename );
But I have no idea how I could execute these functions from anywhere. Maybe someone can give me a hint.
A different idea was to copy the source code inside KiCAD that converts these files inside of KiCAD and use them externally, but I have no idea where to find these.
I have done very little C/C++ coding and would try if there is a way to do these things I am trying to accomplish but don’t know where to start as there seems to be little documentation. How hard would It be?
One last thing I found was KiBot, a repository on GitHub that does some of the things I am asking for, but doesn’t include the option to export a .dsn file. Other similar repositories lack this function as well.
Is there any way to accomplish what I am trying to do? The way it could work is not important to me as long as it’s executable from a local command line.
Thanks in advance!
P.S.: Sorry if I posted in the wrong category or didn’t follow any guidelines. I am new here and don’t quite know yet how to ask.
You are skimping over a big piece of the ugly truth.
From your post it looks like you want an automated output to an autorouter from KiCad, then directly create gerber files and order your PCB’s.
That is a method that is not going to work with the low quality of available autorouters. An autorouter can be a useful tool, but a lot of experienced PCB designers do not use autorouters at all because of the low quality of the PCB layout they generate, and cleanup of the mess can easily be more work then laying the tracks manually in the first place. That is one of the reasons autorouters are not high on the priority list for KiCad. There is also a lot more to routing a PCB then making connections. There are decoupling capacitors with critical wiring demands, length matching, wide high current tracks, GND plane for EMC control, support near connectors to prevent PCB’s from bending during connector insertion so brittle SMD parts don’t break and many more factors.
@paulvdh Thank you for the link. You are absolutely right you seem a lot more knowledgeable than me in this regard. I actually hoped that it would be sufficient for my use case, as I only have to connect a few controller pins with some components with equal-sized tracks, nothing too complex in my opinion. I have not yet tried if the boards I designed with the autorouter are working as I expect. What I did was look at the results, and they seemed okay to me. Not pretty for sure but functional as far as I can tell.
I should probably look into that first and test a bit to see if it’s at least reliable to some degree.
@qu1ck Thanks! I will look into that. that would be halfway there already. Seems like I have to open the GUI anyways to check (and adjust) the output.