A Python package to create, read, modify and write DXF documents — with compatibility across DXF versions R12 through R2018.

MIT License · Python 3.10+ · OS independent

Features

Built for programmers who need precise, reliable DXF processing.

Full DXF Support

Read, write and create DXF versions R12, R2000, R2004, R2007, R2010, R2013 and R2018. Read-only support for older versions.

Preserves Content

Loads and edits DXF files while preserving all content. Unfamiliar third-party tags are retained for future modifications.

Type Annotated

Fully type-annotated codebase. Passes mypy --ignore-missing-imports for confident integration.

Fast C-Extensions

Optional C-extensions bundled in binary wheels on PyPI for Windows, Linux and macOS.

Drawing Add-on

Translate DXF data to render backends. Export to PNG, PDF or SVG via matplotlib, or display interactively with Qt.

Command Line Tool

The ezdxf CLI lets you view, draw, inspect, browse and audit DXF files directly from your shell.

Rich Add-ons

r12writer, dxf2code, pycsg, MTextExplode, text2path, geo interface, mesh exchange, OpenSCAD and ODA File Converter bridges.

ASCII & Binary DXF

Full read and write support for both ASCII DXF and Binary DXF formats.

A Simple Example

Create a new DXF document, add a layer, draw a line and place some text.

Python
import ezdxf
from ezdxf import colors
from ezdxf.enums import TextEntityAlignment

# Create a new DXF document.
doc = ezdxf.new(dxfversion="R2010")

# Create new table entries (layers, linetypes, text styles, ...).
doc.layers.add("TEXTLAYER", color=colors.RED)

# DXF entities (LINE, TEXT, ...) reside in a layout (modelspace,
# paperspace layout or block definition).
msp = doc.modelspace()

# Add entities to a layout by factory methods: layout.add_...()
msp.add_line((0, 0), (10, 0), dxfattribs={"color": colors.YELLOW})
msp.add_text(
    "Test",
    dxfattribs={
        "layer": "TEXTLAYER"
    }).set_placement((0, 0.2), align=TextEntityAlignment.CENTER)

# Save the DXF document.
doc.saveas("test.dxf")

Installation

Install from PyPI. Optional C-extensions are bundled with the binary wheels.

Basic installation

The core package with C-extensions to create, read, modify and write DXF documents:

$ pip install ezdxf

With drawing add-on

Includes matplotlib and PySide6 for rendering DXF to PNG, PDF and SVG and interactive viewing:

$ pip install ezdxf[draw]