Skip to main content

Minimal read-only DWG parser (Rust core + Python API)

Project description

ezdwg

PyPI version

Minimal DWG (R14-R2018 / AC1014-AC1032) reader with a Python API inspired by ezdxf. This project is DWG read-focused while providing a native AC1015 writer for basic entities.

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

Status

  • High-level API (ezdwg.read): R14 / AC1014 (experimental), R2000 / AC1015, R2004 / AC1018, R2007 / AC1021, R2010 / AC1024, R2013 / AC1027, R2018 / AC1032
  • Raw API (ezdwg.raw): R14 / AC1014 (version detect + object headers), R2000 / AC1015, R2004 / AC1018, R2007 / AC1021, plus native AC1024/AC1027/AC1032 support for object listing and LINE/ARC/LWPOLYLINE decode
  • High-level entities: LINE, ARC, LWPOLYLINE, POINT, CIRCLE, ELLIPSE, TEXT, MTEXT, DIMENSION (linear + radius + diameter)
  • Additional raw decode: INSERT (+ 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"):
    print(e.dxftype, e.handle, e.dxf)

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 R14 (AC1014, experimental), R2000 (AC1015), R2004 (AC1018), R2007 (AC1021), R2010 (AC1024), R2013 (AC1027), and R2018 (AC1032)
  • AC1014 currently has stable version detection/object-header listing; entity geometry decoding coverage is limited
  • 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/SEQEND samples are not yet covered in AC1018 test data
  • ARC angles in raw API are radians (high‑level API converts to degrees)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ezdwg-0.8.1.tar.gz (3.4 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ezdwg-0.8.1-cp310-abi3-win_amd64.whl (998.4 kB view details)

Uploaded CPython 3.10+Windows x86-64

ezdwg-0.8.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

ezdwg-0.8.1-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.9 MB view details)

Uploaded CPython 3.10+macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file ezdwg-0.8.1.tar.gz.

File metadata

  • Download URL: ezdwg-0.8.1.tar.gz
  • Upload date:
  • Size: 3.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.1

File hashes

Hashes for ezdwg-0.8.1.tar.gz
Algorithm Hash digest
SHA256 c0a2d69c7296215df0d2082c26b563f9ac82c21f8cc96b773f44e8f74b77ba57
MD5 4585ed87b685359f48c449978603c516
BLAKE2b-256 dc20b1bfa2dd35bb6b5af0cd9d6f8ef9d1f609baf9a3bbb37876de66c5cabdf2

See more details on using hashes here.

File details

Details for the file ezdwg-0.8.1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: ezdwg-0.8.1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 998.4 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.1

File hashes

Hashes for ezdwg-0.8.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1192d94949f720244fc1a86027a31c55fc44cddb19ea07642897468a1a89f0cc
MD5 1c793f91253ca384db7221781db2e8cd
BLAKE2b-256 e127f0baea76c575234352e45bed9f8753b964bb4a483849b537f5d6d2f8f5eb

See more details on using hashes here.

File details

Details for the file ezdwg-0.8.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ezdwg-0.8.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f820337e6f9b127079ea96fb75bc77c7f2c9ca5e37658d27d1bad99dc7c285d2
MD5 37970d68abdd2df7681d0af11b8f041c
BLAKE2b-256 2b182c277d9fdda83e397e1dcc49f1403569438f562cf2e02ec7577f87b1f245

See more details on using hashes here.

File details

Details for the file ezdwg-0.8.1-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for ezdwg-0.8.1-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 72f09fc9c1141c87fba78bd4fa655a313264b6680ab0f1293a589694df1bc013
MD5 ce1dc8214d4a8376c31d7d5d71dd892c
BLAKE2b-256 208ffe0d51c0bf485d107112291cd2848a5dbf57ea0e5b56b4dc76551c7767dd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page