ezmi2d
ezmi2d is an experimental reader for the line-oriented MI drawing format used
by HP ME10 and PTC Creo Elements/Direct Drafting. Its parser and reference
resolver are written in Rust and exposed to Python through PyO3.
The public API provides typed geometry, annotations, and part structure while retaining the complete, byte-preserving raw scan:
import ezmi2d
drawing = ezmi2d.read("drawing.mi")
modelspace = drawing.modelspace()
print(drawing.version, drawing.units, drawing.extents)
print(drawing.encoding, drawing.encoding_source)
for entity in modelspace.query("LIN ARC CIR"):
print(entity.id, entity.mi_type, entity.property_id)
line = drawing.entitydb[10]
if isinstance(line, ezmi2d.Line):
print(line.start, line.end)
for text in modelspace.query("TEXT"):
print(text.text, text.origin, text.height, text.font_name)
for spline in drawing.query("FIL BSPL"):
print(spline.id, spline.mi_type)
for sheet in drawing.sheets:
print(sheet.name, sheet.child_part_indices)
for occurrence in drawing.iter_instances():
print(occurrence.path, occurrence.part.name, occurrence.world_transform)
for dimension in drawing.dimensions:
print(dimension.measurement, dimension.formatted_text, dimension.text_position)
for hatch in drawing.hatches:
print(hatch.pattern, hatch.boundary_loops)
Matplotlib preview
Install the optional plotting dependency and render a decoded fixture to PNG:
pip install "ezmi2d[plot]"
python examples/plot_mi.py tests/data/geometry.mi -o geometry.png
The plotting helper can also be embedded directly:
import matplotlib.pyplot as plt
import ezmi2d
drawing = ezmi2d.read("drawing.mi")
fig, ax = plt.subplots()
ezmi2d.draw(drawing, ax=ax, expand_instances=True)
ax.legend()
fig.savefig("drawing.png", dpi=160)
ezmi2d.draw(Document) renders every decoded part definition once by default;
pass expand_instances=True to traverse nested/shared instances and apply their
transforms, or pass one part to inspect its definition. This is a semantic
diagnostic preview, not a style-faithful MI renderer. Arc.ccw is True for
the corpus-verified orientation code 0; unverified codes are None and are
skipped with a warning rather than guessed.
read() accepts a path or bytes-like object, including the verified
gzip-compressed MI envelope. Point and property pointers are
resolved after all records have been decoded, so forward references work and
dangling or wrong-type references produce source-located diagnostics rather
than aborting the whole drawing.
Text is decoded strictly. The reader checks an explicit encoding= override,
a UTF-8 BOM, MI 3.20-or-newer version metadata, and a #~1 ENCODING:
declaration before conservatively inspecting known text fields in older files.
Supported canonical encodings are utf-8, shift_jis (including cp932 and
windows-31j aliases), and hp-roman8:
drawing = ezmi2d.read("legacy-japanese.mi", encoding="cp932")
text = drawing.query("TEX")[0]
print(text.text, text.text_bytes, text.content_value.encoding)
Invalid or undecidable text is never decoded with replacement characters.
TextValue.text remains None, TextValue.raw_bytes retains the source, and a
source-located diagnostic identifies the bad byte.
The lower-level lossless scanner remains available when inspecting unsupported records or developing new entity decoders:
scan = ezmi2d.scan("drawing.mi")
for record in scan.records:
print(record.section_number, record.record_type, record.raw_bytes)
packed = ezmi2d.scan("drawing.bi")
print(packed.format.compression, packed.container_size, packed.source_size)
assert packed.container_bytes != packed.source_bytes
For compressed inputs, every source span addresses the decompressed logical MI
stream exposed as source_bytes. The exact caller input remains available as
container_bytes. Streaming decompression is bounded independently by
ScanLimits.max_file_size, max_decompressed_size, and
max_compression_ratio.
The CLI emits a raw structural summary or JSON suitable for corpus inspection:
ezmi2d inspect drawing.mi
ezmi2d inspect drawing.mi --json --records
Current scope
- legacy MI 2.10 global metadata, drawing extents, units, and serialized transform values
#~6part ownership and an ezdxf-stylemodelspace(),query(), andentitydb- typed
P,LIN,ARC,FIL,BSPL,CIR, andTEXentities; point references are resolved - De Boor evaluation for
BSPL, including rational weights when a verified layout records them - typed dimension (
DANG,DCHMF,DDIA,DRAD,DSGL) references, measurement, formatted text, placement, DDA/DTF style, and linkedDTVtolerances - drawable
LEDvertices,SYMLcomponents, and associativeHATpatterns/boundaries through typedCOC,PFA, andHAPPrecords - typed
Affine2D, nested/sharedASSEoccurrence traversal, composed child-to-parent transforms, multi-sheet instances, root parts, andDOCU_SHEETlinks - strict UTF-8, Shift_JIS/CP932, and HP Roman-8 text decoding with explicit override support
- typed
PSTAT,ASSP,DTA,DTF,DDA,DLA,DAF, andHAPPproperty models, while retaining unverified numeric enumerations in source order - stable diagnostics for duplicate IDs, bad records, dangling pointers, wrong pointer types, table-of-contents mismatch, and Phase 1 structural problems
UnsupportedEntityfallback with its originalRawRecord; no addressable record is silently discarded merely because its semantic decoder is unavailable- bounded line, section, and
|~scanning with read-only access to every logical MI byte range - streaming gzip decompression with container-size, expanded-size, ratio, truncation, checksum, trailing-data, and concatenated-member guards
Graphic source semantics are exposed as color, linetype, lineweight, resolved property
tables, and LAYER: attributes. Legacy display_values remains a compatibility tuple whose
fourth value is the property count, not visibility. The modern extra header value is retained as
visibility_value; visibility stays None until that code is independently verified.
ARC/FIL retain raw orientation and separately expose
ccw: bool | None; an unknown code is never converted to False.
Modern variable-prefix B-splines expose display_values=None and retain that
prefix as prefix_values instead of guessing a style layout. closed,
periodic, rational, and weights are presence-aware; the currently verified
layouts do not establish those meanings and therefore return None, distinct
from an explicitly recorded False.
For TEX, the serialized 3x3 transform, translation, rotation, width factor, mirror state,
alignment, primary/alternate fonts, line spacing, and multiline content are named. Every post-ID
field remains available through values. Dimension and annotation layouts are named only where
the product corpus has a self-consistent reference or coordinate role; remaining fields,
B-spline prefixes, and assembly relationship values stay lossless bytes. Writers are not
implemented. gzip-wrapped product-generated compressed MI is supported
by content signature. zlib-wrapper, ZIP, UNIX compress, and UNIX pack
signatures are recognized and rejected as unsupported instead of being decoded
by assumption. The available genuine sample is a compressed 2D MI member
inside a Creo bundle, not a separately exported standalone .bi; compatibility
with every Drafting/ME10 .bi generation is therefore not claimed.
See the Python API reference, MI format research, and sample corpus guide. Third-party drawings are not distributed in Git, sdists, or wheels.
The opt-in corpus suite currently exercises 19 MI 2.10 drawings containing 10,166 points, 4,030 lines, 1,059 arcs, 353 fillets, 1,196 circles, 6 B-splines, and 57 text entities. The paired DXF tests compare line endpoints, arc center/start/end points, circle centers/radii, drawing extents, and text content/insertion/height to seven decimal places. Fillets exactly match the additional DXF arcs. Stored B-spline interpolation points and every vertex of the corresponding DXF polylines are evaluated against the decoded curves.
It also verifies a product-generated MI 3.40 / UTF-8 compressed member from a
public Creo bundle: 87,506 compressed bytes expand to 393,805 logical bytes.
Its 853 lines, 187 arcs, 88 B-splines, 76 circles, 57 texts, 88 typed annotations,
11 hatch contours, 9 hatch associations, 25-part hierarchy, and sheet association produce
identical semantic models and diagnostics from compressed and expanded input. All 46 dimensions
resolve their source geometry and point references; all 16 symbols resolve three graphic
components. One COC member is a retained unsupported PLN record.
Distribution
Release automation builds cp310-abi3 wheels for Linux x86-64 and ARM64, macOS universal2, and
Windows x64. Artifact-only smoke tests cover Python 3.10 and 3.14, and the sdist is rebuilt and
installed in a clean job. See docs/releasing.md for the complete release gates
and Trusted Publishing setup.
Development
uv sync --locked --extra dev
uv run maturin develop
uv run pytest
cargo test --workspace
uv run python benchmarks/benchmark_pipeline.py tests/data --warmup 0 --repeat 1 \
--json-output /tmp/ezmi2d-benchmark.json --markdown-output /tmp/ezmi2d-benchmark.md
Parser fuzzing uses nightly Rust and cargo-fuzz:
cargo +nightly fuzz run raw_scan
cargo +nightly fuzz run semantic_read
To fetch and run the separately licensed corpus comparison:
./scripts/fetch_external_samples.sh
uv sync --locked --extra dev --extra corpus
uv run --extra corpus pytest tests/python/test_external_corpus.py
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ezmi2d-0.2.0.tar.gz.
File metadata
- Download URL: ezmi2d-0.2.0.tar.gz
- Upload date:
- Size: 120.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c224102d83152ed74634172ed8b5631520d4551dedee3775cae572e1ba2fad9
|
|
| MD5 |
cd9d9ac8c9a8c1a6db1a94a1e7700d43
|
|
| BLAKE2b-256 |
59aa5b1f514c175087651aa428ad07108e3c7ff934a2f935c8a1a3e28726333b
|
Provenance
The following attestation bundles were made for ezmi2d-0.2.0.tar.gz:
Publisher:
release.yml on monozukuri-ai/ezmi2d
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ezmi2d-0.2.0.tar.gz -
Subject digest:
1c224102d83152ed74634172ed8b5631520d4551dedee3775cae572e1ba2fad9 - Sigstore transparency entry: 2498296132
- Sigstore integration time:
-
Permalink:
monozukuri-ai/ezmi2d@486ac155f1d25c5ab380c7b778e2b488f03a425f -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/monozukuri-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@486ac155f1d25c5ab380c7b778e2b488f03a425f -
Trigger Event:
push
-
Statement type:
File details
Details for the file ezmi2d-0.2.0-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: ezmi2d-0.2.0-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 460.1 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76def5171b00610d18f190242740e90bb9c3b48eecf55d37d6c56264ce3c06b8
|
|
| MD5 |
14ce855668623671a78cec91fe694d46
|
|
| BLAKE2b-256 |
c2df6508fa8fb29bc1ae1cab4044d64f5f71cc491f436b780f97998269aa78ab
|
Provenance
The following attestation bundles were made for ezmi2d-0.2.0-cp310-abi3-win_amd64.whl:
Publisher:
release.yml on monozukuri-ai/ezmi2d
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ezmi2d-0.2.0-cp310-abi3-win_amd64.whl -
Subject digest:
76def5171b00610d18f190242740e90bb9c3b48eecf55d37d6c56264ce3c06b8 - Sigstore transparency entry: 2498296175
- Sigstore integration time:
-
Permalink:
monozukuri-ai/ezmi2d@486ac155f1d25c5ab380c7b778e2b488f03a425f -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/monozukuri-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@486ac155f1d25c5ab380c7b778e2b488f03a425f -
Trigger Event:
push
-
Statement type:
File details
Details for the file ezmi2d-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: ezmi2d-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 606.9 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aca9a9dbbf371ed87f396a0ef69bf46333ab4c981280c61e806b7d257cb8ed1d
|
|
| MD5 |
a2f34661b8d835d39a1eb79f015058ad
|
|
| BLAKE2b-256 |
6b3af82bf84c6fe216495c58ac0771a9fd093cfbd7899c37b823ff999c52ecfa
|
Provenance
The following attestation bundles were made for ezmi2d-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on monozukuri-ai/ezmi2d
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ezmi2d-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
aca9a9dbbf371ed87f396a0ef69bf46333ab4c981280c61e806b7d257cb8ed1d - Sigstore transparency entry: 2498296200
- Sigstore integration time:
-
Permalink:
monozukuri-ai/ezmi2d@486ac155f1d25c5ab380c7b778e2b488f03a425f -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/monozukuri-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@486ac155f1d25c5ab380c7b778e2b488f03a425f -
Trigger Event:
push
-
Statement type:
File details
Details for the file ezmi2d-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: ezmi2d-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 596.2 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47f3eb4360d1ce913eca51eaf736247b3a5009970dabb47491564ba471a8084f
|
|
| MD5 |
5a17c3972014003fe9b0662324781838
|
|
| BLAKE2b-256 |
0d1c601afa9cc8f811507fb19d18fdf1e34ef18e83ce2d3621b02d341df2d64f
|
Provenance
The following attestation bundles were made for ezmi2d-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on monozukuri-ai/ezmi2d
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ezmi2d-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
47f3eb4360d1ce913eca51eaf736247b3a5009970dabb47491564ba471a8084f - Sigstore transparency entry: 2498296228
- Sigstore integration time:
-
Permalink:
monozukuri-ai/ezmi2d@486ac155f1d25c5ab380c7b778e2b488f03a425f -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/monozukuri-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@486ac155f1d25c5ab380c7b778e2b488f03a425f -
Trigger Event:
push
-
Statement type:
File details
Details for the file ezmi2d-0.2.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.
File metadata
- Download URL: ezmi2d-0.2.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.10+, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9aa2509e9ae4aedfb65681573564bce6d7a5d6fb5a56c6163bb264ca5cae7cc5
|
|
| MD5 |
26150bd55a6769eafd666e6967a05677
|
|
| BLAKE2b-256 |
2a3f263e9db03299803889a527e9e4d74741170efae7cfcd9f630d550a449d50
|
Provenance
The following attestation bundles were made for ezmi2d-0.2.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:
Publisher:
release.yml on monozukuri-ai/ezmi2d
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ezmi2d-0.2.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl -
Subject digest:
9aa2509e9ae4aedfb65681573564bce6d7a5d6fb5a56c6163bb264ca5cae7cc5 - Sigstore transparency entry: 2498296250
- Sigstore integration time:
-
Permalink:
monozukuri-ai/ezmi2d@486ac155f1d25c5ab380c7b778e2b488f03a425f -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/monozukuri-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@486ac155f1d25c5ab380c7b778e2b488f03a425f -
Trigger Event:
push
-
Statement type: