ezdwg
DWG (R13-R2018 / AC1012-AC1032) reader with a Python API inspired by ezdxf. This project is a DWG read-focused parser with growing high-level entity coverage while providing a native AC1015 writer for basic entities.
Documentation: https://monozukuri-ai.github.io/ezdwg/
Status
- High-level API (
ezdwg.read): R13 / AC1012 and R14 / AC1014 (experimental), R2000 / AC1015, R2004 / AC1018, R2007 / AC1021, R2010 / AC1024, R2013 / AC1027, R2018 / AC1032 - Raw API (
ezdwg.raw): R13 / AC1012 and R14 / AC1014 (version detect + object headers), R2000 / AC1015, R2004 / AC1018, R2007 / AC1021, plus native AC1024/AC1027/AC1032 support for object listing andLINE/ARC/LWPOLYLINEdecode - High-level entities include LINE, ARC, LWPOLYLINE, POINT, CIRCLE, ELLIPSE, TEXT, MTEXT, DIMENSION, INSERT/MINSERT, HATCH, and SPLINE
- Raw API exposes the corresponding entity decoders plus low-level POLYLINE/VERTEX helpers
- Output units/angles: high-level API returns ARC angles in degrees
Install
Install from PyPI:
pip install ezdwg
Plotting (optional):
pip install "ezdwg[plot]"
DWG to DXF conversion (optional, ezdxf backend):
pip install "ezdwg[dxf]"
If you want to contribute or develop locally, you can install from source: Rust toolchain is required (PyO3 build).
git clone https://github.com/monozukuri-ai/ezdwg.git
cd ezdwg
maturin develop
pip install -e .
Quick Start
import ezdwg
doc = ezdwg.read("path/to/file.dwg")
msp = doc.modelspace()
for e in msp.query(
"LINE LWPOLYLINE ARC CIRCLE ELLIPSE POINT TEXT MTEXT "
"DIMENSION INSERT MINSERT HATCH SPLINE"
):
print(e.dxftype, e.handle, e.dxf)
doc.modelspace() yields only model-space entities (block-definition contents and
paper-space entities are excluded via each entity's stored placement);
doc.paperspace() yields paper-space entities and doc.entities() everything in
the file, with e.dxf["owner_handle"] / doc.entity_placement(handle) to
partition them yourself.
Drawing units and header variables:
import ezdwg
doc = ezdwg.read("path/to/file.dwg")
doc.units # "millimeters" ($INSUNITS; None for R14)
doc.header_variables()["extmin"] # model-space extents, unit formats, ...
Plot in matplotlib:
import ezdwg
doc = ezdwg.read("path/to/file.dwg")
doc.plot()
CLI
uvx ezdwg --version
uvx ezdwg inspect examples/data/line_2000.dwg
uvx ezdwg inspect examples/data/line_2000.dwg --verbose
uvx --from "ezdwg[dxf]" ezdwg convert examples/data/line_2000.dwg /tmp/line_2000_out.dxf
uvx --from "ezdwg[dxf]" ezdwg convert examples/data/arc_2000.dwg /tmp/arc_2000_out.dxf --types "ARC" --dxf-version R2010
uvx ezdwg write examples/data/line_2000.dwg /tmp/line_2000_out.dwg --types "LINE" --dwg-version AC1015
DWG to DXF
ezdxf is used as the DXF writing backend.
import ezdwg
result = ezdwg.to_dxf(
"examples/data/line_2000.dwg",
"/tmp/line_2000_out.dxf",
types="LINE ARC LWPOLYLINE",
dxf_version="R2010",
)
print(result)
Or from an already opened document/layout:
doc = ezdwg.read("examples/data/line_2000.dwg")
doc.export_dxf("/tmp/line_2000_out.dxf")
DWG to DWG (Native AC1015 Writer)
import ezdwg
result = ezdwg.to_dwg(
"examples/data/line_2000.dwg",
"/tmp/line_2000_rewrite.dwg",
version="AC1015",
)
print(result)
Or from an already opened document/layout:
doc = ezdwg.read("examples/data/line_2000.dwg")
doc.export_dwg("/tmp/line_2000_rewrite.dwg", version="AC1015")
Examples
Sample DWG files are available under examples/data/.
python examples/basic_read.py
python examples/query_types.py
python examples/plot.py
python examples/text_mtext.py
python examples/dimensions.py
python examples/raw_insert_2004.py
python examples/convert_to_dxf.py
Low-Level API
If you need raw decode access:
from ezdwg import raw
raw.decode_line_entities("path/to/file.dwg")
Limitations
- Native DWG write currently targets AC1015 only
- Native DWG write supports a subset of entities: LINE/RAY/XLINE/POINT/ARC/CIRCLE/LWPOLYLINE/TEXT/MTEXT
- High-level API supports R13 (AC1012, experimental), R14 (AC1014, experimental), R2000 (AC1015), R2004 (AC1018), R2007 (AC1021), R2010 (AC1024), R2013 (AC1027), and R2018 (AC1032)
- AC1012/AC1014 currently have stable version detection/object-header listing; entity geometry decoding coverage is limited (the R13/R14 common entity header now follows the ODA layout, older heuristics remain as fallbacks)
- AC1021/AC1024/AC1027/AC1032 use native decode for LINE/ARC/LWPOLYLINE/POINT/CIRCLE/ELLIPSE and are regression-tested against paired DXF samples
- TEXT/MTEXT/DIMENSION decoders now use version-aware common header paths internally; R2007+ dedicated sample regression coverage is still pending
- AC1021/AC1024/AC1027/AC1032 entity style/layer color resolution is currently best-effort on some files
- Legacy
POLYLINE/VERTEX/SEQENDsamples are not yet covered in AC1018 test data - ARC angles in raw API are radians (high‑level API converts to degrees)
Metadata
Release files for ezdwg 0.12.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ezdwg-0.12.8.tar.gz | 280.0 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ezdwg-0.12.8-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| ezdwg-0.12.8-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| ezdwg-0.12.8-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64 | Details |
Total release size: 4.8 MB
Release files / ezdwg-0.12.8.tar.gz
| Download URL | ezdwg-0.12.8.tar.gz |
|---|---|
| Size | 280.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be7c88407440ae1c775eb5d9544e2ebf7b7b21c63fa67fe037f363c4b2ca4b56
|
|
BLAKE2b-256 checksum How to use checksums |
73061786d07dc10af96d6b4ddc6fb270ff3f461af1dbb442fcfe939915761bd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / ezdwg-0.12.8-cp310-abi3-win_amd64.whl
| Download URL | ezdwg-0.12.8-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
3ffbe9816ab63b51ce4de1617ecac87d8f5e1fc9be7210cce9c588b73a76b8b1
|
|
BLAKE2b-256 checksum How to use checksums |
e90e1d54a8398146a8f3c57cd7d2b0dc1fd1eeb72348c9ca5ce03742dcaca184
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / ezdwg-0.12.8-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | ezdwg-0.12.8-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
f79c51daf8582619cfd43dadf896c1feb7d6ad3b0910797ef59d02d90fe5a53a
|
|
BLAKE2b-256 checksum How to use checksums |
d800dd0689f8a7f4499cf42ed694e32b58431e58b3c94644a2888c2020cccfd6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / ezdwg-0.12.8-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | ezdwg-0.12.8-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.10 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
b7b9a5515738fe8c8cb9269b473f3f06d1bcea3ed7ae6a048817dfbe93fc2a58
|
|
BLAKE2b-256 checksum How to use checksums |
2ad1719afe3f90b61e4e6d713a39ac8dbc3eea138128c2f39ab016599e7a2b04
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|