Is anyone else writing their footprint files by hand? There are advantages/disadvantages of course.
Some Con's
- you become responsible for managing your own footprint source library
- the process can be tedious in the early stages, until you build up your repertoire
- there is a new workflow required
- possibly more difficult when collaborating
Some Pro's
- complete control of your source, and a source-code history
- finer resolution in making backups from individual file, to project level
- much better reuse of bits and bobs (really, it's all code)
- better control over global parameters like your choice of resolution
A small example from my last project might help clarify what I'm talking about.
#
# Homeboard Edge Cuts for 200 x 130 4-layer board with CK7101 switch cutout and Kobiconn DIN cutout
# (C) Will Turner, 5 December 2023
# || Change this each edit!
(module AAA_footprints:board-edge-cuts-Homeboard_32 (layer F.Cu) (tedit 62AAB011)
(descr "Triton Homeboard")
(tags "Triton")
(attr virtual)
# Component identifier from schematic editor.
(fp_text reference REF** (at 0 -26) (layer Dwgs.User) (effects (font (size 1 1) (thickness 0.05)) (justify left)))
# Component label from schematic editor.
(fp_text value board-edge-cuts-Homeboard_32 (at 0 -24) (layer Dwgs.User) (effects (font (size 1 1) (thickness 0.05)) (justify left)))
# ^^ Also change this each edit!
#
# Edge Cuts
#
#
# Edge cuts need to be carefully planned since tracks may not cross.
# Also, closed polygon :-).
#
#
# CK7101 Switch cut-out is 12.5mm wide by 21mm high.
#
# Top LH corner is x = 3, y = 51.5
# Starting at the upper left hand corner, and working anti-clockwise
(fp_arc (start 2.5 2.5) (end 0 2.5) (angle 90) (layer Edge.Cuts) (width 0.005))
# Launch point for the switch cutout x = 0, y = 51.5 - e
(fp_line (start 0 2.5) (end 0 51.49999) (layer Edge.Cuts) (width 0.005))
# Straight across to RH edge of the cut out, x = 3 + 12.5, y = 51.5 - e
(fp_line (start 0 51.49999) (end 15.5 51.49999) (layer Edge.Cuts) (width 0.005))
# Down the RH edge x = 3 + 12.5, y = 51.5 + 21
(fp_line (start 15.5 51.49999) (end 15.5 72.5) (layer Edge.Cuts) (width 0.005))
# To the left hand edge of the cutout x = 3, y = 90 + 21
(fp_line (start 15.5 72.5) (end 3 72.5) (layer Edge.Cuts) (width 0.005))
# Up to the LH corner completes the cut-out x = 3, y = 96.5
(fp_line (start 3 72.5) (end 3 51.5) (layer Edge.Cuts) (width 0.005))
# Back to the LH edge x = 0, y = 96.5
(fp_line (start 3 51.5) (end 0 51.5) (layer Edge.Cuts) (width 0.005))
# Down to the corner
(fp_line (start 0 51.5) (end 0 127.5) (layer Edge.Cuts) (width 0.005))
# Bottom left hand corner heading right
(fp_arc (start 2.5 127.5) (end 2.5 130) (angle 90) (layer Edge.Cuts) (width 0.005))
(fp_line (start 2.5 130) (end 397.5 130) (layer Edge.Cuts) (width 0.005))
# Board width starts here ^^^^^
# Bottom right hand corner heading up
(fp_arc (start 397.5 127.5) (end 400 127.5) (angle 90) (layer Edge.Cuts) (width 0.005))
(fp_line (start 400 127.5) (end 400 2.5) (layer Edge.Cuts) (width 0.005))
# Top right hand corner heading left
(fp_arc (start 397.5 2.5) (end 397.5 0) (angle 90) (layer Edge.Cuts) (width 0.005))
(fp_line (start 397.5 0) (end 2.5 0) (layer Edge.Cuts) (width 0.005))
# Instruction to JLCPCB staff. Text centre: x = 7 + 12.5 / 2, y = 51.5 + 21 / 2
(fp_text user "-- cut out --" (at 9.25 62.0) (layer F.SilkS) (effects (font (size 1 1) (thickness 0.153))))
#
# Kobicon DIN Connector cut out
#
# Centre is at x = 92.00, y = 33.75, radius 98.25 - 92.00 = 6.25mm
(fp_arc (start 92.00 33.75) (end 98.25 33.75) (angle 360) (layer Edge.Cuts) (width 0.005))
(fp_text user "-- cut out --" (at 92.00 33.75) (layer F.SilkS) (effects (font (size 1 1) (thickness 0.153))))
)
#
# end
#
At the top level of my schematic I put an "artifact" associated with this footprint. My list of "artifacts" also includes a fiducial, tooling holes, a visible "fascia" (essentially the silk layer), and a border "grid" marking the board territory.
Deeper into the schematic, each component has a supporting source code file.
As a starter, you can save the base code for a footprint from the footprint editor "File->Export Footprint" menu item. Edit, then bring it back into the footprint editor with "File->Import Footprint from KiCAD file".
I am now managing all of my footprints like this. What do you think?
A couple of notes if you try this
- you can copy the code above and give it a go, but I was in the process of making my board much bigger.
- the footprint editor will not respect your source code. It likely will delete all of your comments when you rexport code for example.
- rounding errors especially if a footprint is rotated will be much more visible
- you will want to get your fancy calculator, notebook, and pen out of the drawer.
Edit(s) : anticipated, especially if I decide to add stuff to the lists above.