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 and native AC1015 / AC1032 writers for basic entities and nested blocks.

Documentation: https://monozukuri-ai.github.io/ezdwg/

For Rust projects, use ezdwg-core without a Python dependency:

cargo add ezdwg-core

See the Rust crate guide for reading and writing examples, or the Rust API reference.

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")

New drawings are built with ezdwg.new() (editable, see the guide) or, for converters that only write, ezdwg.new_streaming(): the same tables and add_* methods, but every entity goes to the native writer at once and the Python side stays small whatever the drawing size.

Path/Document exports select model space. Use strict=True to reject unsupported or undecoded entities and detected attribute loss before writing. Otherwise inspect result.skipped_by_type and result.diagnostics. Referenced layers, simple line patterns, basic text styles, Japanese text, units and placement attributes are preserved. Referenced blocks and attached attributes are kept as a graph. Complete source document metadata remains outside the scope. See native writer scope and external checks.

Use AC1032 to preserve RGB colors and mixed-language Unicode text:

drawing = ezdwg.new("AC1032")
drawing.layers["図面_도면"] = {"true_color": 0x73B9FF}
drawing.modelspace().add_text(
    "日本語 한국어 العربية 😀", (0, 0), height=2,
    layer="図面_도면", true_color=0x123456,
)
drawing.save("unicode.dwg")

AC1032 supports basic model-space entities and static blocks; see the AC1032 writer scope.

Create and Edit DWG

import ezdwg

drawing = ezdwg.new()  # AC1015, no input file needed
msp = drawing.modelspace()
line = msp.add_line((0, 0), (10, 5), color_index=1)
msp.update(line, end=(20, 5))
drawing.save("created.dwg")  # strict validation by default

edited = ezdwg.read("created.dwg").edit()
edited.modelspace().add_circle((5, 5), radius=2)
edited.save("edited.dwg")

The editable snapshot supports basic entities, block definitions, nested INSERTs and single-line ATTDEF/ATTRIB attributes. Queries return live entities; use update(), mutate entity.dxf, or call delete(entity). Saving validates the drawing, writes a temporary sibling file, and atomically replaces the destination. See the editing guide for table editing, import limitations and diagnostics.

Blocks use the same geometry methods in local coordinates:

part = drawing.blocks.new("Part", base_point=(0, 0, 0))
part.add_circle((0, 0), radius=2)
part.add_attdef("ID", "default", insert=(0, 3), height=1)
ref = msp.add_blockref("Part", insert=(10, 20), rotation=30)
msp.add_attrib(ref, "ID", "P-001", insert=(10, 23), height=1)
drawing.save("blocks.dwg")

Attribute placement is explicit; add_attrib does not automatically transform an ATTDEF or synchronize defaults. See blocks and attributes.

Paper space is a single layout (Layout1) with a sheet in millimetres and viewports that show model space at a scale; view_height / height is the scale denominator, so an A3 sheet plotted 1:1 shows the model at 1:100 here:

drawing.set_paper(420, 297)  # ISO A3 landscape, margins (left, bottom, right, top) optional
psp = drawing.paperspace()
psp.add_viewport((210, 148.5), 400, 277, view_center=(10000, 5000), view_height=277 * 100)
psp.add_text("A3 1:100", (10, 5), height=5)  # title block entities live on the sheet
drawing.save("sheet.dwg")

The sheet's own viewport is written automatically in front of the user viewports.

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 targets AC1015 (default) and AC1032 (RGB and Unicode; a smaller entity subset)
  • Native DWG write supports a subset of entities: LINE/RAY/XLINE/POINT/ARC/CIRCLE/ELLIPSE/SPLINE/SOLID/TRACE/3DFACE/LWPOLYLINE/POLYLINE_2D/POLYLINE_3D/TEXT/MTEXT/INSERT/ATTDEF/ATTRIB/HATCH/DIMENSION/IMAGE/VIEWPORT, including nested block definitions, rendered dimension blocks, raster image definitions and one paper-space layout (Drawing.paperspace(), Drawing.set_paper()); true colours are rounded to the nearest ACI
  • Paper space of an existing drawing is not imported by Document.edit() / to_dwg; only new paper-space content is written
  • 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
  • Ordinary legacy 2D/3D polylines have native roundtrip tests and opt-in ODA import/export coverage for AC1015/AC1018/AC1027; fitted polylines and mesh writing remain unsupported
  • ARC angles in raw API are radians (high‑level API converts to degrees)

Metadata

Release files for ezdwg 0.19.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.19.0
File Size Uploaded Provenance Actions
ezdwg-0.19.0.tar.gz 510.7 kB Without provenance Details for ezdwg-0.19.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for ezdwg 0.19.0
File Actions
ezdwg-0.19.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for ezdwg-0.19.0-cp310-abi3-win_amd64.whl
ezdwg-0.19.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for ezdwg-0.19.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
ezdwg-0.19.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for ezdwg-0.19.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
ezdwg-0.19.0-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 10.12+ x86-64, macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64) Details for ezdwg-0.19.0-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Total release size: 9.3 MB

Release files / ezdwg-0.19.0.tar.gz

Download URL ezdwg-0.19.0.tar.gz
Size 510.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3dc5c210d880b79b3d86d3218040a573dcd486f1d805ec1720cc6c9ea89209ef
BLAKE2b-256 checksum
How to use checksums
98742b17f754cec430c6f7c2a6c6bcf6cc699ccfda339a06aa39dfbaa2e2f445
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ezdwg-0.19.0-cp310-abi3-win_amd64.whl

Download URL ezdwg-0.19.0-cp310-abi3-win_amd64.whl
Size 1.7 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
5bb4ce7bfa3a1f44eb963c438a90625c9aaf39568eba9d7d1034b6303bad00fb
BLAKE2b-256 checksum
How to use checksums
1cbf8bde12147c0081dd0db4e68478c8f3485e9552c1743ac669a106f7fc90fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ezdwg-0.19.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL ezdwg-0.19.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.9 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
c6fd182e9e74fed2efbe1e3cf1c405c36c30fceae92759a27c2fa6de8d9e51d3
BLAKE2b-256 checksum
How to use checksums
5bb350ed219cc66b2785bb06f58253fd534b310b6f7996843e0e358b32fea62e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ezdwg-0.19.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL ezdwg-0.19.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.8 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
3c8c63b97593c2871fec0e3f42b73c67e160cfd60479b422028f522d3eecd48c
BLAKE2b-256 checksum
How to use checksums
1ff8f0750af5e5ca55fd300b8053b6b3919ad4cbdc4bbe776775bbf3e055c131
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ezdwg-0.19.0-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Download URL ezdwg-0.19.0-cp310-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl
Size 3.4 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
133c56de2eae8e49bb6bd4cb08f5fb22e5af608432e14830d293a31717f0d9e8
BLAKE2b-256 checksum
How to use checksums
478d67014694a762788acb7cb91d4641b3e40a765de059905ab007c05a850d28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for ezdwg 0.19.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.19.0 This release

5 release files No provenance

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