I have a project that aims to replicate the original version of the Apple II motherboard:
If you’re familiar with the design of the Apple II and II+, you’ll know they use several dozen chips in DIP packages (mostly 14- and 16-pin, with smaller quantities of 8- and 24-pin chips, and one 40-pin 6502). These were all (or almost all) socketed for ease of maintenance.
The DIP footprint libraries offer images of chips and images of sockets that render nicely in the 3D viewer or in a STEP export, but there’s nothing that models a chip in a socket. It’s easy to fix this manually, though: go to the model settings, copy the name of the chip model to another one with _Socket
appended in the right place, and raise the chip model by 4 mm. This is easy enough to do for a small number of socketed chips, but doing this for the 78 sockets needed here was going to be tedious.
I knocked together an awk script that modifies the kicad_pcb file to add socket models. It’s at the repo named above, but it’s small enough to include here:
$0 ~ "\\(model \"\\${KICAD9_3DMODEL_DIR}/Package_DIP.3dshapes/DIP-" && $0 !~ "_Socket.step" {n=substr($0, index($0,"/DIP-")+5); n=substr(n, 0, length(n)-6); print "(model \"${KICAD9_3DMODEL_DIR}/Package_DIP.3dshapes/DIP-"n"_Socket.step\""; for (i=0; i<10; i++) {getline; print;}; print "(model \"${KICAD9_3DMODEL_DIR}/Package_DIP.3dshapes/DIP-"n".step\""; print "(offset (xyz 0 0 4)) (scale (xyz 1 1 1)) (rotate (xyz 0 0 0)))"; next}
{print}
Save it to a file, and invoke it with something like this:
awk -f add_sockets.awk my_board.kicad_pcb >my_board_socketed.kicad_pcb
Use the standalone PCB editor to verify that the script didn’t introduce any errors (it is a quick-and-dirty script with not much error checking), then (optionally) overwrite the original file with the “socketed” file.
(A Python script built around a library such as kicad-skip could be made more robust, but kicad-skip doesn’t support PCB files from KiCad 9, last I checked.)