A Python utility for converting DXF (Drawing Exchange Format) files to KCL (KittyCAD Language) code. This tool enables seamless integration between traditional CAD workflows and the modern, code-first approach of KittyCAD.
This converter transforms 2D sketches from DXF files into executable KCL code that can be used in KittyCAD's Modeling App (now Zoo Design Studio). The tool is specifically designed for 2D sketches in the XY plane.
- Converts DXF entities to KCL code
- Supports common geometric primitives:
- Lines
- Circles
- Arcs
- Polylines
- Maintains geometric relationships and dimensions
- Generates clean, readable KCL code
- Currently only supports 2D sketches in the XY plane
- Splines are not currently supported
- Complex DXF features like blocks or hatches are not implemented
-
Clone this repository:
git clone https://github.com/Joe-Spencer/dxf2kcl.git cd dxf2kcl -
Install dependencies:
pip install ezdxf
Basic usage:
python dxf2kcl.py input.dxf output.kcl- Create or obtain a DXF file with your 2D sketch
- Run the converter:
python dxf2kcl.py my_sketch.dxf my_sketch.kcl
- Open the generated KCL file in KittyCAD's Modeling App
The converter reads the DXF file using the ezdxf library, processes each supported entity, and generates equivalent KCL code. The process involves:
- Parsing the DXF file structure
- Identifying supported entities
- Converting coordinates and geometric properties
- Generating appropriate KCL commands
- Writing the result to a KCL file
Contributions are welcome! Here are some ways you can contribute:
- Add support for additional DXF entities
- Improve conversion accuracy
- Enhance error handling
- Add tests and examples
Please feel free to submit issues and pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.