ezdxf - DXF Drawing Manipulation

1.4.3 · active · verified Fri Apr 10

ezdxf is a comprehensive Python package designed for creating, reading, modifying, and writing DXF (Drawing Exchange Format) documents. It supports a wide range of DXF versions from R12 to R2018 and aims to hide complex DXF details while providing extensive capabilities. The library is actively maintained, with frequent updates for bug fixes and new features, currently at version 1.4.3.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a new DXF document, add basic geometric entities (a line and a circle) to its modelspace, and save it to a DXF file. This is the fundamental workflow for generating DXF drawings with ezdxf.

import ezdxf

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

# 2. Add entities to the modelspace (the main drawing area)
msp = doc.modelspace()

# 3. Add a line from (0,0) to (10,0)
msp.add_line((0, 0), (10, 0))

# 4. Add a circle with center (0,0) and radius 5
msp.add_circle((0, 0), 5)

# 5. Save the DXF document
doc.saveas("my_first_drawing.dxf")
print("Created 'my_first_drawing.dxf'")

view raw JSON →