Python modules to render CAD drawings for the plate for a custom computer keyboard.
The plate is a flat plane with holes in it in to which the switch modules for the keys are snapped. Usually it is hidden inside the keyboard case, but hand-built keyboards tend to leave it exposed as the top of the case.
This software does the same thing as online services like the swillkb Plate & Case Builder and Keyboard CAD Assistant: it takes the serialized data from the Keyboard Layout Editor and writes DXF and SVG files that might be converted in to instructions for a CNC mill or laser cutter.
Part of the motivation for rolling my own rather than exploiting the Swill version was plan to use acrylic or wood rather than metal for the plate, so I need to create an ‘under-plate’ support layer. This has almost the same design but with a few cutouts that allow the switches to clip on to the top layer.
Create a Python virtualenv with virtualenvwrapper or otherwise and install the dependencies:
mkvirtualenv plato
pip install -r requirements.txt
Now run the command that writes the plate.
./write_plate.py x1.kle
This reads x1.kle
and generate sDXF and SVG files for the plate,
the under-plate, an indicative diagram of the key cap outlines,
and a combined image that shows what the combination
might look like. The DXF version is hard to display if you don’t have
CAD software, which is where the SVG file is convenient—it can be
loaded in to your favourite web browser and you should be able to zoom
and pan with your browser’s ususal controls.
The SVG version sets the line widths to a representative kerf width, that is, it represents the thin slice of material that is destroyed by the laser. The effective edge of the holes will therefore be the outer edge of the outline of the hole.
There is also an option to create a size tester—useful to calibrate the cutting tool you are using.
./write_plate -t size
This draws 11 key switches with kerf value ranging from -0.20 to 0.50. Negative kerf does not make literal sense but has the effect of widening the hole to larger than the expected 14mm so we can be sure the range of sizes definitely goes from too loose to too tight.