Create a KiCad footprint or PCB from a DXF file
For example, from
generate a footprint:
It will read the DXF file and:
- converts arcs to lines
- find arcs and lines which compose a closed-loop graphic and output a polygon
- lines which do not form a closed polygon are output as lines
Each layer is handled seperately, the layer name is converted to a layer name in the KiCad file.
By default, entities on all layers are written to KiCad layer "F.Cu", and entities identified as polygons will be filled with a solid fill. Entities that form non-closed polylines are output as lines (v5) or polylines (v6) depending on KiCad version.
dxf2kicad can also generate a KiCad PCB (.kicad_pcb) using the --pcb option.
By default, dxf2kicad assumes the DXF file is specified in mm. KiCad output files are always mm. The input units can be set by the following methods in order of priority:
- command line option
-u
- settings file layer value
- settings file global value
Valid units are :
mm
mil
inch
A settings file may be specified with the -s
option, to give finer control over conversion. A settings file
is a JSON file. The -w
option may be used to create a template file containing defaults.
Default settings file:
{
"units": "mm",
"layers": [
{
"source_layer": "0",
"dest_layer": "F.Cu",
"type": "filled",
"units": "",
"offset_x": 0,
"offset_y": 0
}
],
"distance_error": 0.025,
"min_line_width": 0.15,
"kicad_version": "5",
"horiz_align": "left",
"vert_align": "bottom"
}
units
units of DXF file
dxf_merge is a utility to extract/copy/merge DXF files. For example, if you have a DXF file for each layer, they can be merged into one DXF file for input to dxf2kicad.
See tests
for some footprint examples.
test_pcb
contains a PCB example.
- Supports LINE, ARC, ELLIPSE, POLYLINE, LWPOLYLINE, HATCH, INSERT
- CIRCLE on a drill layer will create a hole (plated through hole)
- each line must connect with another line or arc's beginning or end point to within 0.025mm
- if there are multiple lines with overlapping end points, the algorithm may fail to identify polygons correctly
See https://www.python.org/downloads/.
> pip install ezdxf
> git clone https://github.com/bobc/dxf2kicad_mod.git
> cd dxf2kicad_mod
Use your favorite CAD to tool to create a DXF file
Use following command line to generate footprint
> python dxf2kicad_mod.py <dxf_file_name> <footprint_file.kicad_mod>
Add the folder containing the footprint to KiCad's Footprint Library Table.