Create Kicad
footprint from DXF
file. This simple and dirty script was
designed for my own purpose a few years back. At that time, I was using Kicad
to design a simple PCB, but the shape of footprint could not be designed using
Kicad
footprint design tool. A workaround is to create the shape in CAD tools
and convert it to the Kicad
footprint format. Hence this work was a bit of
hacking.
A generated footprint from a dxf file:
The corresponding kicad_mod
file which could be viewed
by Kicad
footprint viewer.
It will read the DXF
file and find lines and arcs (only supporting these two
types so far) which compose a close-loop graphic, it converts arcs to lines and
connected all lines together using fp_poly
command in kicad_mod
file. Each
layer is handled separately, the layer name is converted to layer name in
kicad_mod
file.
- it only support lines and arcs so far, but it could fulfill my requirement so far. In the future, I may add more shape support (by converting the shapes to lines)
- each line must connect with another line or arc's beginning or end point very precisely, as the algorithm searches the points location only. If it is overlapped, it will fail to find the connecting point but it will provide some hint to tell you where it is lost, you may check the location if it is overlapped or not connected well.
- There must not be a line or arc on top another lines in the same layer due to the same reason above. Sometimes, people draws two lines on the same location, and it very hard to find where. Again the message in command line will provide some hints for you.
https://github.com/mozman/dxfgrabber.git
clone https://github.com/pandysong/dxf2kicad_mod.git
cd dxf2kicad_mod
python dxf2kicad_mode "Your-dxf-file-name-here" > "your kicad_mod file.kicad_mod"
Install pipenv
is not yet installed:
pip install pipenv
clone https://github.com/pandysong/dxf2kicad_mod.git
cd dxf2kicad_mod
pipenv install
pipenv shell
Then use it as normal
python dxf2kicad_mod.py test_data.dxf > test_data.kicad_mod