Skip to main content

ezdwg

PyPI version

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 (2D entities), R2000 / AC1015, R2004 / AC1018, R2007 / AC1021, R2010 / AC1024, R2013 / AC1027, R2018 / AC1032
  • Raw API (ezdwg.raw): the same versions, with the per-type decode_* functions and the table, style and placement functions
  • 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 .

For release version updates, run uv run scripts/bump_version.py <version>. The root Cargo.toml is the single version source for Rust and Python; the command refreshes the lock files. See Releasing for details.

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.

Layouts and viewports:

import ezdwg

doc = ezdwg.read("path/to/file.dwg")
for name, layout in doc.layouts().items():
    print(name, layout["model"], layout["active"], layout["paper_width"], layout["paper_height"])

for viewport in doc.paperspace().query("VIEWPORT"):
    dxf = viewport.dxf
    scale = dxf["height"] / dxf["view_height"]  # R2000+; the first viewport of a sheet is the sheet itself

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[plot]" ezdwg plot examples/data/line_2000.dwg
uvx --from "ezdwg[plot]" ezdwg plot examples/data/line_2000.dwg -o /tmp/line_2000.png --dpi 200
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

plot displays model-space entities in a matplotlib window, or opens an SVG preview in your browser when no interactive backend is available. Use -o / --output to save a PNG, SVG, or PDF without opening a viewer; --types and --title filter entities and set the title. For local development, run uv run --extra plot ezdwg plot path/to/file.dwg.

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 decode the 2D entity types with the layouts of the ODA specification (LINE, ARC, CIRCLE, ELLIPSE, POINT, LWPOLYLINE, POLYLINE_2D, TEXT, MTEXT, ATTRIB/ATTDEF, INSERT/MINSERT, HATCH, SOLID, TRACE, 3DFACE, SPLINE, LEADER, TOLERANCE, MLINE, SHAPE, DIMENSION), with block membership, block names and dimension blocks, and the 3D polylines and meshes. R13/R14 have no lineweights and no layer plot flag, and their viewports state a window but no view
  • AC1021/AC1024/AC1027/AC1032 use native decode for LINE/ARC/LWPOLYLINE/POINT/CIRCLE/ELLIPSE and are regression-tested against paired DXF samples
  • TEXT/MTEXT/ATTRIB/ATTDEF of R2007 and later are read from the string stream of the object and regression-tested on one drawing saved in every version (R14 to R2018)
  • AC1021/AC1024/AC1027/AC1032 entity style/layer color resolution is currently best-effort on some files
  • Legacy POLYLINE/VERTEX/SEQEND samples 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.14.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ezdwg 0.14.0
File Size Uploaded
ezdwg-0.14.0.tar.gz 370.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for ezdwg 0.14.0
File
ezdwg-0.14.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
ezdwg-0.14.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
ezdwg-0.14.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
ezdwg-0.14.0-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: 6.9 MB

Release files / ezdwg-0.14.0.tar.gz

Download URL ezdwg-0.14.0.tar.gz
Size 370.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c4008375aa5f46d8ec4bb9ed2d4f6e07add5bf950e5bcd0ac831ea65e3c5c3a1
BLAKE2b-256 checksum
How to use checksums
4398b8ceb5d481351fbe90de36d3e9035dad672c5f797f47c3a9575d16dd56d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","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.14.0-cp310-abi3-win_amd64.whl

Download URL ezdwg-0.14.0-cp310-abi3-win_amd64.whl
Size 1.3 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
40101f139abea52766656399ca5953a7fa6f8da8d0a9d6cf45943ec1391a125e
BLAKE2b-256 checksum
How to use checksums
0e1778dde2e23f1a1c364d44407a6afd97e155a7e171e5bcb191a79a8273737e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","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.14.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL ezdwg-0.14.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.4 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
561f5168dab7cdc0da21c65f50d2949d4d039fdb033d572a5e152a168145f7e2
BLAKE2b-256 checksum
How to use checksums
0df3ce4ad5447bde987ebeb97041386763078eadcc9dc0ad1664f9a20f89a6d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","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.14.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL ezdwg-0.14.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.3 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
0c67fb94f14f07d2272361b7840e40f060c0a2d121e3729223c445a096c4dcae
BLAKE2b-256 checksum
How to use checksums
d9e2091c89f6213c74c65b1e4caa92c3218f6c0ce6781bd65cc8d9e15d55c425
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","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.14.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Download URL ezdwg-0.14.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Size 2.5 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
962c039fdfbb156cc778ea9f7a15c62a69aa19ee6f02eeac6e000df31f313c45
BLAKE2b-256 checksum
How to use checksums
4bf8cada8452f42e18d95e1c1d0a4b9bc0da98a3ee1365379877b0a71e5ca928
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","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}
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page