by mozman

mozman / ezdxf

Python interface to DXF

288 Stars 76 Forks Last release: Not found MIT License 3.2K Commits 60 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:



A Python package to create and modify DXF drawings, independent from the DXF version. You can open/save every DXF file without losing any content (except comments), Unknown tags in the DXF file will be ignored but preserved for saving. With this behavior it is possible to open also DXF drawings that contains data from 3rd party applications.


  • ezdxf is a Python package to create new DXF files and read/modify/write existing DXF files
  • the intended audience are developers
  • requires at least Python 3.6
  • OS independent
  • tested with CPython & pypy3 on Windows 10 & ubuntu-latest by GitHub Actions
  • additional required packages: pyparsing and for testing geomdl (aka NURBS-Python)
  • MIT-License
  • read/write/new support for DXF versions: R12, R2000, R2004, R2007, R2010, R2013 and R2018
  • additional read support for DXF versions R13/R14 (upgraded to R2000)
  • additional read support for older DXF versions than R12 (upgraded to R12)
  • read/write support for ASCII DXF and Binary DXF
  • preserves third-party DXF content

Included Extensions

  • The
    add-on is a translation layer to send DXF data to a render backend, interfaces to matplotlib, which can export images as png, pdf or svg, and PyQt5 are implemented.
  • geo
    add-on to support the
  • r12writer
    add-on to write basic DXF entities direct and fast into a DXF R12 file or stream
  • iterdxf
    add-on to iterate over DXF entities of the modelspace of really big (> 5GB) DXF files which do not fit into memory
  • Importer
    add-on to import entities, blocks and table entries from another DXF document
  • dxf2code
    add-on to generate Python code for DXF structures loaded from DXF documents as starting point for parametric DXF entity creation
  • Plot Style Files (CTB/STB) read/write add-on

A simple example:

import ezdxf

Create a new DXF document.

doc = ezdxf.new(dxfversion='R2010')

Create new table entries (layers, linetypes, text styles, ...).

doc.layers.new('TEXTLAYER', dxfattribs={'color': 2})

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': 7}) msp.add_text( 'Test', dxfattribs={ 'layer': 'TEXTLAYER' }).set_pos((0, 0.2), align='CENTER')

Save DXF document.


Example for the r12writer, which writes a simple DXF R12 file without in-memory structures:

from random import random
from ezdxf.addons import r12writer

MAX_X_COORD = 1000 MAX_Y_COORD = 1000

with r12writer("many_circles.dxf") as doc: for _ in range(100000): doc.add_circle((MAX_X_COORDrandom(), MAX_Y_COORDrandom()), radius=2)

The r12writer supports only the ENTITIES section of a DXF R12 drawing, no HEADER, TABLES or BLOCKS section is present, except FIXED-TABLES are written, than some additional predefined text styles and line types are available.


Install with pip for Python 3.6 and later:

pip install ezdxf

Install latest development version with pip from GitHub:

pip install git+https://github.com/mozman/[email protected]

or from source:

python setup.py install




Documentation of development version at https://ezdxf.mozman.at/docs

Documentation of latest release at http://ezdxf.readthedocs.io/


The source code of ezdxf can be found at GitHub, target your pull requests to the




Questions and feedback at Google Groups:


[email protected]

Questions at Stack Overflow:

Post questions at stack overflow and use the tag


Issue tracker at GitHub:



Please always post questions at the forum or stack overflow or open an issue at github to make answers available to other users as well.

[email protected]

Feedback is greatly appreciated.


We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.