Skip to main content

ezsxf

A fast SXF parser and drawing converter for Python, implemented in Rust with PyO3.

ezsxf supports both SXF formats:

  • P21 (ISO-10303-21 based)
  • SFC (SXF feature blocks)

Status

The SFC parser covers all 34 feature types in the SXF Ver.3.1 SFC specification, including resolved drawing/compound-figure/composite-curve structure. The P21 reader currently exposes the generic Part 21 entity representation.

Features

  • Parse P21 and SFC from file path, text, or bytes
  • Decode SFC files as UTF-8 or Windows Shift-JIS/CP932 without lossy replacement
  • Strict and lenient parsing modes
  • Structured parse output (header, entities, typed_features, model, warnings)
  • Resolve layer/style code tables, compound-figure placements, and hatch boundaries
  • Decode ATRF/ATRU/ATRS attribute attachments separately from drawing groups
  • Validate compound-figure placement counts, hierarchy, and drawing-group transforms
  • Convert SFC drawings to AutoCAD 2007 ASCII DXF without another runtime dependency
  • Draw SFC drawings with the optional matplotlib backend
  • Python API + CLI (ezsxf / python -m ezsxf)

Installation

From source (recommended currently)

python -m venv .venv
source .venv/bin/activate
pip install maturin
maturin develop

Install the plotting extra when using the matplotlib backend:

pip install ".[plot]"

Quick Start

import ezsxf

result = ezsxf.parse_sfc("./data/D0LS004ZSFC/D0LS004Z.SFC", strict=True)
print(result["format"])          # "sfc"
print(len(result["typed_features"]))
print(result["model"]["sheet"]["component_ids"])

Convert the original input or an already parsed result to DXF:

ezsxf.to_dxf("./data/D0LS004ZSFC/D0LS004Z.SFC", "drawing.dxf")

parsed = ezsxf.parse_sfc("./data/D0LS004ZSFC/D0LS004Z.SFC")
dxf_text = ezsxf.to_dxf(parsed)

Draw with matplotlib and save through the returned Axes:

ax = ezsxf.plot("./data/D0LS004ZSFC/D0LS004Z.SFC")
ax.figure.savefig("drawing.png", dpi=200, bbox_inches="tight")

Both backends share the same hierarchy, placement, layer, color, line type, line width, text, dimension, and hatch conversion. Curves are converted to polylines; use curve_segments to control the approximation resolution.

Drawing conversion currently targets SFC input. Externally defined symbols are shown as insertion markers, while externally defined and tiled hatch patterns retain only boundaries marked visible by the SXF data.

CLI

# smoke test
python -m ezsxf

# parse to JSON
python -m ezsxf parse sfc ./data/D0LS004ZSFC/D0LS004Z.SFC --pretty
python -m ezsxf parse p21 ./data/D0LS004ZP21/D0LS004Z.P21 --lenient

# convert SFC to DXF
python -m ezsxf to-dxf ./data/D0LS004ZSFC/D0LS004Z.SFC drawing.dxf

# save or interactively display a matplotlib drawing
python -m ezsxf plot ./data/D0LS004ZSFC/D0LS004Z.SFC drawing.png --dpi 200
python -m ezsxf plot ./data/D0LS004ZSFC/D0LS004Z.SFC

Development

cargo fmt --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test

# Python-level tests
python -m unittest discover -s tests -p 'test_*.py' -v

Repository Layout

  • src/*.rs: Rust parser, resolved model, and PyO3 bindings
  • src/ezsxf/: Python API, CLI, DXF writer, matplotlib backend, and stubs
  • data/: SXF sample datasets used for validation
  • resources/: SXF specification PDFs (reference only)

License

MIT License. See LICENSE.

Download files

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

Source Distribution

ezsxf-0.1.0.tar.gz (71.1 kB view details)

Uploaded Source

Built Distributions

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

ezsxf-0.1.0-cp39-abi3-win_amd64.whl (452.4 kB view details)

Uploaded CPython 3.9+Windows x86-64

ezsxf-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (579.5 kB view details)

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

ezsxf-0.1.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.0 MB view details)

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

File details

Details for the file ezsxf-0.1.0.tar.gz.

File metadata

  • Download URL: ezsxf-0.1.0.tar.gz
  • Upload date:
  • Size: 71.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for ezsxf-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d4baebffbffed53fdf87ff6ac8d36662082f4029eac46ec5bcab372547c5b8ba
MD5 3efc1da4311ad5a1dfd5df1af1246dbf
BLAKE2b-256 149fa179ac55d43539f8bcd379965e0104b561d9d8ecbdbc863ff2e29b2de0c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for ezsxf-0.1.0.tar.gz:

Publisher: release.yml on monozukuri-ai/ezsxf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ezsxf-0.1.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: ezsxf-0.1.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 452.4 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for ezsxf-0.1.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 24f7e117a73785874e7b06ab4a95a12fe4f2120aef12d52256ca2c282f772139
MD5 dfc1436be387acc9b76328a4be16f55a
BLAKE2b-256 fa7c45686895f8e3a8520d5701b54ffdb8f16e7ba048d502341b8added2050b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for ezsxf-0.1.0-cp39-abi3-win_amd64.whl:

Publisher: release.yml on monozukuri-ai/ezsxf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ezsxf-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ezsxf-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5c66898290e366e97933d41ab18a65dc4dffdf537f987ec91d35db2a110ac9f1
MD5 a46ba076b551682a2ece55df09cf02a0
BLAKE2b-256 4fa4b0de87fcecadce9496b9c2ac8f9d05f1baeb163f7bc4a30c29305e05c875

See more details on using hashes here.

Provenance

The following attestation bundles were made for ezsxf-0.1.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on monozukuri-ai/ezsxf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ezsxf-0.1.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for ezsxf-0.1.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 0361322f8bd91bca77246a72deba7d5e8cffe859ccf0a47045c8aa75b9878c67
MD5 f58191d86a7a7c6fb31bd4ddbd336b23
BLAKE2b-256 fb4bbeded12e13f68db3ffe48a47bcadac3df354b04b2cbaf55fc938d9d84977

See more details on using hashes here.

Provenance

The following attestation bundles were made for ezsxf-0.1.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: release.yml on monozukuri-ai/ezsxf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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