Using dxf files to create board edges in KiCAD
Last updated: Dec 30, 2023
Using dxf files to create board outlines in KiCAD
The problem
Drawing complex PCB board outlines in KiCAD is tricky with the tools provided in the PCB editor. I often get spurious errors from the DRC (design rule check) tool that I have gaps inbetween the segments of the PCB outline e.g. between curves and straight edges.
How can I draw complex PCB outlines in KiCAD that are continuous?
Summary
Create your outline using cadquery. Export the outline as a dxf file. Import the dxf file into FreeCAD. Use the kicad plugin in FreeCAD to convert the dxf file to a board edge.
Details
Create your dxf file using cadquery. Other packages may well work just as well but I haven’t tried them.
Open up the dxf file in FreeCAD. Install the KiCAD plugin: Tools, Addon Manager, Workbenches, kicadStepUpMod
Restart FreeCAD. Select the KiCadStepUp plugin from the dropdown list in the middle of the top menu bar. This list defaults to ‘Start’ on startup. A new menubar with many incomprehensible symbols appears. We will use two of these, as shown in the image below.
File, Import, your_dxf_file.dxf
You need to select all of the parts of the dxf file that you want to use as your board outline. This might be tedious if there are lots of them. I’m not familiar enough with FreeCAD to know if there is a ‘select all’ button. I press down on the control key and select all of the segments that I need for the board outline.
Now click on the ‘ksu 2D object (or DXF) to Sketch’ button on the toolbar that was created when you installed the plugin. See the annotated screenshot of the menu bar below.
Scroll to the bottom of the Model window on the left in the Combo View pane.
Select the sketch that has just been created. See the screenshot below.
Click on the ‘ksu Push Sketch to PCB Edge’ button in the menu bar - shown in the earlier screenshot.
You will get the option to push the outline directly to your KiCAD PCB file, into the outline layer. I’ve not tried this. I’ve always created a separate file.
Import the newly created file into your KiCAD PCB using the menu options File, Append Board.
Run DRC to check this is all good. Use the 3D viewer (View, 3D Viewer) to enjoy the glory of a fully joined up outline!
End thoughts
It’s a bit of a kefuffle to get from the dxf file to the board outline, but it works. I’m grateful for all of the people who create the open-source and free-to-use software that I used in this post.