I'm just getting into PCB design and I generally have trouble learning how to use GUIs with menus and mouse clicking. Do some engineers use something more like code to generate PCBs?
-
7I wouldn't recommend writing plain gerber files... – Huisman Jul 31 '19 at 13:37
-
32PCB layout is mostly a visual task - moving and rotating stuff to make it fit. Doing it by code sounds painful. – JRE Jul 31 '19 at 13:38
-
3There are usually hot keys for most (if not all) menu items; most tools allow text input for location and orientation (but it is a lot more painful to do that than just move things with a mouse). I use the text tools to get precise placement of things like vias and differential pairs. – Peter Smith Jul 31 '19 at 13:42
-
4Some CAD packages are more clicky than others. In my experience, Orcad Allegro is the worst for making you go through a lot of pointless GUI actions to get the simplest things done. Diptrace is pretty much the easiest and most fluid user experience. PADS is a very nice toolchain with an intuitive UI and a lot of high-end features. PADS is for engineers who like to get things done, Orcad is for masochists. :D – Jul 31 '19 at 13:56
-
2There are keyboard shortcuts and unique cases where programmatic generation of patterns make sense, but PCB layout is mostly an interactive graphical task. In contrast situations where the *logic* dominates over the physical embodiment like FPGA and (many parts of) ASIC design typically are driven by hardware description languages feeding logic compilers feeding automated place & route tools. If we were still building mainframe processors from big boards full of TTL there might be a comparable design flow for HDL to PCB... but fortunately we aren't. – Chris Stratton Jul 31 '19 at 15:08
-
2The GUI is pretty much indispensable. But it may be possible to do a lot of stuff without a mouse or with minimal clicking if you learn all the keyboard shortcuts. – user57037 Jul 31 '19 at 15:40
-
2It’s strange that we use Hardware Description Languages for digital chip design but not for PCBs. – Michael Aug 01 '19 at 07:25
-
Scripts. Just about everything that matters supports scripts or can be hijacked to do so. Helps with the repetitive things, but the rest is still done by hand. – Mast Aug 01 '19 at 10:31
-
@Michael: chips don't have the varieties of mechanical constraints PCBs do. – whatsisname Aug 01 '19 at 16:39
5 Answers
Altium has a scripting language, several different languages, in fact. In some cases it may make sense to use algorithms, for example to create repetitive layouts or parts placed precisely in certain positions.
For example, I've seen it used to place parts (LEDs) in a circular pattern, though with their introduction of polar coordinate snap grids that's much less likely to be worth the hassles.
We've used algorithms to create shapes (think antennas and that kind of thing) directly in .dxf format which can then be imported into a copper layer.
In general, code is poorly suited for PCB layout purposes, particularly so for the routing task.

- 376,485
- 21
- 320
- 842
In EAGLE CAD, everything you can do with a mouse you can do from the command line. It also has a user language that you can essentially program in.

- 29,274
- 4
- 44
- 109
-
2Very useful when doing patterns, etc. Even if you do 99% of the layout manually you can still arrange parts/features with code. – Wesley Lee Jul 31 '19 at 16:20
-
1Often, I code in Matlab or a text processor to output scripting language. – Scott Seidman Jul 31 '19 at 16:21
-
3
-
1This is one of the key advantages of Eagle. Once you start, you'll only use the command line. – D Duck Aug 01 '19 at 08:25
I use code to generate the netlist for my PCBs. (It's far, far quicker to write a for-loop to build an N-bit multiplexer than to laboriously draw all that stuff in a schematic.) Fortunately, KiCAD netlist files are just text, in a format that's undocumented but reasonably easy to reverse-engineer.
I wrote a small C# library that lets me type in what I want connected to what (in terms of reusable parametric blocks of circuitry), and it automatically spits out a netlist. Now I can just import that straight into KiCAD and start building the PCB, without having to waste an hour or so uselessly drawing a schematic for it. (The library even does some very basic checks to ensure my instructions aren't completely bogus, although I suspect KiCAD itself would do that job better.)
KiCAD PCB files, on the other hand, are also text, but appear to be far too complex to generate programmatically. Which is a shame, because KiCAD defaults to dumping all the components directly on top of each other, requiring me to spend 20+ minutes tediously separating them out again so I can see what the hell I'm doing. (KiCAD has a nasty habit of trying to move the text rather than the component it's attached to, presumably just to make PCBs harder to design?)
Perhaps some day I'll manage to also automate the initial component layout; I suspect, as others have said, that the actual "PCB design" bit will always involve the GUI though.

- 1,701
- 2
- 18
- 23
-
It would be nice to hook one of [graphviz's](https://www.graphviz.org/) layout engines up to KiCAD for the initial placement. I've used graphviz to make LTspice files for very simple layouts and it worked reasonably well. – pipe Jul 31 '19 at 16:24
-
3There are some tools in kicad to spread out the components initially, it's called "Global spread and place". To avoid moving text, I just usually disable the text layers for layout. After all one can see the text by clicking if needed. – jpa Aug 01 '19 at 08:32
I wouldn't recommend it, but if you really desire you can write PCB artwork yourself, without any PCB program. The code looks like this:
G90*
1 G70*
2 G54D10*
3 G01X0Y0D02*
4 X450Y330D01*
5 X455Y300D03*
6 G54D11*
7 Y250D03*
8 Y200D03*
9 Y150D03*
10 X0Y0D02*
11 M02*
12The line numbers at far right are not part of the file. Examining this file without any prior knowledge of Gerber one would correctly deduce that each line represents a particular machine command and that the asterisk (*) is the end of command character. There seems to be different kinds of commands: instructions beginning with G, D, M and x,y coordinate data.
Source: https://www.artwork.com/gerber/appl2.htm
Here is a spec that shows the different commands

- 75,799
- 36
- 80
- 208
-
2Gerber (RS-274X) is related to the G-code (RS-274) files used in CNC programming. I do sometimes write G-code directly with a text editor for simple 2.5D tasks. – Spehro Pefhany Jul 31 '19 at 15:39
-
5Just an observation: if you are direct coding gerbers, then there is no design rule check taking place other than you visualizing in your head. I can't imagine typing out a text gerber file, sending it to fab house without ever opening the file in a GUI tool at just looking at it, unless you are a next level savant of some sort. – user57037 Jul 31 '19 at 15:43
-
1I wasn't sure if Gerber was related to G-code, but I had a suspicion. If one needed to write a simple top layer for an antenna or filter it might not be too bad to code something up yourself. I've only edited G-code, but never tried to write it. – Voltage Spike Jul 31 '19 at 15:44
-
@mkeith some people are visual, some people learn otherwise. I can't imagine not checking with a gerber layer tool or something like that, but for some people it might be easier to look at the code. – Voltage Spike Jul 31 '19 at 15:45
-
6Anyone who can work better with G-code than a visual tool of some sort for a complex board would definitely be an exceptional person. Anyone who can work directly in G-code and be productive would have to be considered a savant, I think. – user57037 Jul 31 '19 at 15:55
-
1I don't know all 7.5 billion people in the world, but I can say confidently there is not a single person in existence that would do a better job looking at gerber code than a graphical display for any serious, multi-layer professional-purpose boards. – whatsisname Jul 31 '19 at 22:18
If you are using Kicad, see some of the videos from the talks at the first KiCon (2019) on Youtube. A couple of the talks were explicitly about the presenters writing tools to generate the parts, one also about the connections. At least one used python, which is baked in as a scripting language.

- 19
- 1
-
1Could you please elaborate and add links to videos, and to the tools. (Waving towards a conference might be a worthwhile comment, but it doesn't quite qualify as an answer.) – Nick Alexeev Aug 02 '19 at 04:14