icadkit 0.3.11__tar.gz → 0.3.12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {icadkit-0.3.11 → icadkit-0.3.12}/Cargo.lock +2 -2
- {icadkit-0.3.11 → icadkit-0.3.12}/Cargo.toml +1 -1
- {icadkit-0.3.11 → icadkit-0.3.12}/PKG-INFO +1 -1
- {icadkit-0.3.11 → icadkit-0.3.12}/docs/changelog.md +11 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/docs/drawing.md +1 -1
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/drawing.py +55 -14
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_drawing.py +76 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/COMMERCIAL-LICENSE.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/LICENSE +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/LICENSES/Apache-2.0.txt +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/LICENSES/PolyForm-Noncommercial-1.0.0.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/LICENSES/parasolid-core-MIT.txt +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/LICENSES/rust-dependencies.txt +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/README.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/THIRD_PARTY_NOTICES.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/corpus/README.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/corpus/generate.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/corpus/public.jsonl +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/Cargo.toml +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/LICENSE +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/build.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/src/compression.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/src/container.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/src/document.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/src/error.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/src/header.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/src/lib.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/src/limits.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/src/native.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/src/parasolid.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/src/parts.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/src/provenance.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/src/reader.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/src/record.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/src/resource.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/src/schema.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/src/trailer.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/src/views.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/tests/container.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/tests/header.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-core/tests/resources.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-python/Cargo.toml +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-python/LICENSE +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-python/src/brep.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-python/src/document.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-python/src/geometry.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-python/src/lib.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/crates/icad-python/src/schema.rs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/docs/api.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/docs/csg.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/docs/license.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/docs/native.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/docs/parameters.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/docs/parts.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/docs/preview.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/docs/references.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/docs/roadmap.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/docs/saved-bodies.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/docs/shapes.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/docs/support.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/docs/trailer.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/docs/viewer.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/docs/writing.md +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/pyproject.toml +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/scripts/bump_version.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/scripts/check_license.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/scripts/check_public_tree.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/scripts/test_publication.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/scripts/test_versions.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/scripts/verify_artifacts.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/scripts/verify_corpus.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/scripts/verify_install.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/scripts/verify_native_corpus.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/__init__.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/__main__.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/_core.pyi +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/_csg_occt.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/_preview_bridge.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/_saved_occt.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/_shape_occt.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/_viewer/index.html +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/_viewer/viewer.css +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/_viewer/viewer.js +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/_viewer_io.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/api.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/cli.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/container.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/csg.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/document.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/errors.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/geometry.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/models.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/native.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/parameters.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/parts.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/preview.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/py.typed +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/references.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/saved.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/schema.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/shape.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/trailer.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/versions.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/viewer.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/views.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/src/icadkit/write.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/conftest.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/drawing_fixtures.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/fixture_builders.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/geometry_fixtures.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/parameter_fixtures.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/part_fixtures.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/preview_fixtures.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/saved_fixtures.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_api.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_cli.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_container.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_corpus.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_csg.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_distribution.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_extrusion.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_followup_parts.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_geometry.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_inspect.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_legacy_parts.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_mirrors.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_native.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_native_corpus.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_native_round.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_parameters.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_part_profiles.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_part_semantics.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_parts.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_parts_material.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_preview.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_profile_shapes.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_references.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_resource_cli.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_resources.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_saved.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_shape.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_trailer.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_v7_parts.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_v8l4_boundary.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_version_geometry.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_viewer.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_views_placement.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/test_write.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/trailer_fixtures.py +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/viewer_assembly_browser.mjs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/viewer_browser.mjs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/tests/viewer_mirror_browser.mjs +0 -0
- {icadkit-0.3.11 → icadkit-0.3.12}/uv.lock +0 -0
|
@@ -89,7 +89,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
|
89
89
|
|
|
90
90
|
[[package]]
|
|
91
91
|
name = "icad-core"
|
|
92
|
-
version = "0.3.
|
|
92
|
+
version = "0.3.12"
|
|
93
93
|
dependencies = [
|
|
94
94
|
"flate2",
|
|
95
95
|
"parasolid-core",
|
|
@@ -99,7 +99,7 @@ dependencies = [
|
|
|
99
99
|
|
|
100
100
|
[[package]]
|
|
101
101
|
name = "icad-python"
|
|
102
|
-
version = "0.3.
|
|
102
|
+
version = "0.3.12"
|
|
103
103
|
dependencies = [
|
|
104
104
|
"icad-core",
|
|
105
105
|
"parasolid-core",
|
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- Leader notes whose drawn leader has more than three points (the tip, two
|
|
8
|
+
or more elbows and the end of the shelf; a 2026 production drawing) read
|
|
9
|
+
`complete` with the full `path`. 0.3.11 unpacked exactly three points and
|
|
10
|
+
the whole drawing failed with "too many values to unpack".
|
|
11
|
+
- `read_drawing()` keeps an entity whose record raises while it is decoded
|
|
12
|
+
(`ValueError`, `IndexError`, `struct.error`) in place as `invalid` with a
|
|
13
|
+
`drawing.entity_error` diagnostic instead of failing the drawing; size
|
|
14
|
+
limits still raise `LimitExceededError`.
|
|
15
|
+
|
|
5
16
|
### Added
|
|
6
17
|
|
|
7
18
|
- `DrawingText.underline`: view labels ("A-A", "Z矢視図") append one line
|
|
@@ -140,7 +140,7 @@ Layer values outside the observed one-byte layout remain unqualified.
|
|
|
140
140
|
| Elliptical arc of V5-V7 (type 89, 448 bytes, subtype `0x10`) | `DrawingCurve` as a free curve with the ellipse words retained in the appended chunk; byte 7 of the header is `0x90` in these records (3D-derived drawings) | The 16 records of the corpus read `complete` |
|
|
141
141
|
| Underlined text (type 21 with one line item) | `DrawingText.underline`: the start and end of the 48-byte line item that view labels ("A-A", "Z矢視図") append after their runs, any byte order; the fixed words differ from a plain text (header +14 = 3, +46 counts the run and the item, +60 = 0x40, +76 = `03 01`) and read `complete` for one line | The item's appearance bytes are not kept separately |
|
|
142
142
|
| 3D projection frame (type 211) | Attribute record (`drawing.attribute_record`): a composite without drawn items whose words hold a 3×3 rotation matrix (isometric in the corpus) | Not drawn |
|
|
143
|
-
| Leader note (types 22, 34, 44) | `DrawingNote`: the text runs (one per line), the arrowhead (a corner, the tip, the other corner), the drawn leader (tip,
|
|
143
|
+
| Leader note (types 22, 34, 44) | `DrawingNote`: the text runs (one per line), the arrowhead (a corner, the tip, the other corner), the drawn leader (tip, one or more elbows, end; the older type 34 stores a two-point leader) and the arrow parameters; type 44 is a leader without text (partial, `drawing.note_text`) | Hidden alternative items are retained in `items` |
|
|
144
144
|
| Symbol (types 212, 14, 28) | `DrawingSymbol`: drawn point markers, lines, arcs and vectors (a point with one, two or three vectors: the strokes of surface-texture symbols, type 28), the text runs (UTF-16LE or CP932) and the nested member list of a group as opaque ranges; `raw_kind` is the saved byte at `+31` (1 point markers, 50 labels); type 14 is a block of text lines | A run that does not decode is skipped with `drawing.symbol_text` |
|
|
145
145
|
| Line information (type 224) | `DrawingSymbol` with the saved `name` (`Line`, `Junction`, `Connection Mark`, symbol names of P&ID and circuit drawings): the drawn lines, circles (marker `0x0444`) and text runs of the framed item stream | Records without a framed item stream (cable names, tables) are attribute records (`drawing.attribute_record`) |
|
|
146
146
|
| Point with attributes (type 1, 128 bytes) | The point; the appended attribute record is retained | Connection points of P&ID symbols |
|
|
@@ -246,8 +246,9 @@ class DrawingNote:
|
|
|
246
246
|
The record frames attribute blocks, the text runs (``texts``, one per
|
|
247
247
|
line; ``text`` is the first) and ``vectors`` items: the arrowhead
|
|
248
248
|
(``arrow``: a corner, the tip and the other corner), the drawn leader
|
|
249
|
-
(``path``: the tip,
|
|
250
|
-
|
|
249
|
+
(``path``: the tip, one or more elbows and the end of the shelf under the
|
|
250
|
+
text; two points in the oldest layouts) and hidden alternatives that are
|
|
251
|
+
not drawn. Balloons (the older type 34)
|
|
251
252
|
add the drawn ``circle`` (centre, radius) around the text. ``arrow_width``
|
|
252
253
|
and ``arrow_angle`` (degrees) come from the attribute block shared with
|
|
253
254
|
dimensions.
|
|
@@ -1085,18 +1086,19 @@ def _note(b: bytes, order: str, at: int) -> DrawingNote | None:
|
|
|
1085
1086
|
continue
|
|
1086
1087
|
if not item.raw_marker & 0x40:
|
|
1087
1088
|
continue # hidden alternatives are retained in items, not drawn
|
|
1088
|
-
if len(item.points)
|
|
1089
|
-
|
|
1090
|
-
if not path:
|
|
1091
|
-
path = item.points
|
|
1092
|
-
else:
|
|
1093
|
-
issue("drawing.note_item", offset, "Additional leader item")
|
|
1089
|
+
if len(item.points) < 2:
|
|
1090
|
+
issue("drawing.note_item", offset, "Leader item with fewer than two points")
|
|
1094
1091
|
continue
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1092
|
+
if len(item.points) == 3 and arrow is None:
|
|
1093
|
+
p, q, r = item.points
|
|
1094
|
+
if _symmetric_legs(p, q, r):
|
|
1095
|
+
arrow = (p, q, r)
|
|
1096
|
+
continue
|
|
1097
|
+
if not path:
|
|
1098
|
+
# the drawn leader: the tip and the end (older layouts), the tip, the elbow
|
|
1099
|
+
# and the end of the shelf, or further elbows between them (a four-point
|
|
1100
|
+
# leader in a 2026 production drawing failed to unpack in 0.3.11)
|
|
1101
|
+
path = item.points
|
|
1100
1102
|
else:
|
|
1101
1103
|
issue("drawing.note_item", offset, "Additional leader item")
|
|
1102
1104
|
if not path:
|
|
@@ -1970,6 +1972,40 @@ def _entity(
|
|
|
1970
1972
|
)
|
|
1971
1973
|
|
|
1972
1974
|
|
|
1975
|
+
def _unreadable_entity(view: View, entry: ViewEntry, exc: Exception) -> DrawingEntity:
|
|
1976
|
+
"""An entity whose record raised while it was decoded.
|
|
1977
|
+
|
|
1978
|
+
It stays in place as ``invalid`` with the error in its diagnostics, so one
|
|
1979
|
+
record of an unobserved layout does not fail the whole drawing (0.3.12; a
|
|
1980
|
+
production drawing was lost to a single leader note before that).
|
|
1981
|
+
"""
|
|
1982
|
+
at = entry.byte_range.start
|
|
1983
|
+
return DrawingEntity(
|
|
1984
|
+
f"drawing@{at}",
|
|
1985
|
+
view.view_id,
|
|
1986
|
+
entry.byte_range,
|
|
1987
|
+
entry.owner_offset,
|
|
1988
|
+
None,
|
|
1989
|
+
None,
|
|
1990
|
+
None,
|
|
1991
|
+
None,
|
|
1992
|
+
None,
|
|
1993
|
+
None,
|
|
1994
|
+
None,
|
|
1995
|
+
None,
|
|
1996
|
+
None,
|
|
1997
|
+
"invalid",
|
|
1998
|
+
(
|
|
1999
|
+
Diagnostic(
|
|
2000
|
+
"invalid",
|
|
2001
|
+
"drawing.entity_error",
|
|
2002
|
+
at,
|
|
2003
|
+
f"Entity record could not be decoded: {type(exc).__name__}: {exc}",
|
|
2004
|
+
),
|
|
2005
|
+
),
|
|
2006
|
+
)
|
|
2007
|
+
|
|
2008
|
+
|
|
1973
2009
|
def _read_drawing(
|
|
1974
2010
|
document: "Document", limits: DrawingLimits | None, view_limits: ViewLimits | None
|
|
1975
2011
|
) -> DrawingIndex:
|
|
@@ -1990,7 +2026,12 @@ def _read_drawing(
|
|
|
1990
2026
|
statuses.append(view.status)
|
|
1991
2027
|
for entry in view.entries:
|
|
1992
2028
|
if entry.kind == "entity":
|
|
1993
|
-
|
|
2029
|
+
try:
|
|
2030
|
+
entity = _entity(document, view, entry, limits)
|
|
2031
|
+
except LimitExceededError:
|
|
2032
|
+
raise
|
|
2033
|
+
except (ValueError, IndexError, struct.error) as exc:
|
|
2034
|
+
entity = _unreadable_entity(view, entry, exc)
|
|
1994
2035
|
entities.append(entity)
|
|
1995
2036
|
statuses.append(entity.status)
|
|
1996
2037
|
else:
|
|
@@ -1679,3 +1679,79 @@ def test_three_d_projection_frames_are_attribute_records():
|
|
|
1679
1679
|
)
|
|
1680
1680
|
assert e.status == "unsupported" and e.primitive is None and e.raw_type == 211
|
|
1681
1681
|
assert any(d.code == "drawing.attribute_record" for d in e.diagnostics)
|
|
1682
|
+
|
|
1683
|
+
|
|
1684
|
+
# --- leader items with more than three points, per-entity decode guard (0.3.12) ----
|
|
1685
|
+
|
|
1686
|
+
|
|
1687
|
+
def test_leader_note_with_an_extra_elbow_is_read_as_a_four_point_path():
|
|
1688
|
+
# A 2026 production drawing (iCAD SX 2D, type 22) saved a leader whose drawn item
|
|
1689
|
+
# has four points: the tip, two elbows and the end of the shelf. 0.3.11 unpacked
|
|
1690
|
+
# exactly three and the whole drawing failed with "too many values to unpack".
|
|
1691
|
+
from icadkit import LeaderNote2D
|
|
1692
|
+
from icadkit.write import _item
|
|
1693
|
+
|
|
1694
|
+
writer = _sheet_writer()
|
|
1695
|
+
writer.add_entities(
|
|
1696
|
+
"XY", [LeaderNote2D(("注記",), (50.0, 50.0), (70.0, 70.0), (100.0, 70.0))]
|
|
1697
|
+
)
|
|
1698
|
+
(e,), doc = _entities(writer, (22,))
|
|
1699
|
+
assert e.note.path == ((50.0, 50.0), (70.0, 70.0), (100.0, 70.0))
|
|
1700
|
+
record = bytearray(doc.source_bytes(e.byte_range))
|
|
1701
|
+
# the drawn leader is the last item: 8 bytes of framing + 6 doubles
|
|
1702
|
+
size = struct.unpack_from("<H", record, len(record) - 56)[0]
|
|
1703
|
+
marker = struct.unpack_from("<H", record, len(record) - 54)[0]
|
|
1704
|
+
assert (size, marker) == (56, 0x0344)
|
|
1705
|
+
del record[-56:]
|
|
1706
|
+
drawn = e.note.items[-1]
|
|
1707
|
+
record += _item(
|
|
1708
|
+
"<",
|
|
1709
|
+
0x0344,
|
|
1710
|
+
drawn.line_width,
|
|
1711
|
+
drawn.color_index,
|
|
1712
|
+
(50.0, 50.0, 20.0, 20.0, 30.0, 20.0, 50.0, 20.0),
|
|
1713
|
+
)
|
|
1714
|
+
struct.pack_into("<I", record, 0, len(record))
|
|
1715
|
+
again = (
|
|
1716
|
+
icadkit.read(drawing([bytes(record)], order="little", version=b"\0\x08\0\x03"))
|
|
1717
|
+
.read_drawing()
|
|
1718
|
+
.entities[0]
|
|
1719
|
+
)
|
|
1720
|
+
assert again.status == "complete" and again.note is not None
|
|
1721
|
+
assert again.note.path == (
|
|
1722
|
+
(50.0, 50.0),
|
|
1723
|
+
(70.0, 70.0),
|
|
1724
|
+
(80.0, 70.0),
|
|
1725
|
+
(100.0, 70.0),
|
|
1726
|
+
)
|
|
1727
|
+
assert again.note.arrow is not None and again.note.arrow[1] == (50.0, 50.0)
|
|
1728
|
+
assert again.note.box[2] >= 100.0
|
|
1729
|
+
|
|
1730
|
+
|
|
1731
|
+
def test_an_entity_record_that_raises_does_not_fail_the_drawing(monkeypatch):
|
|
1732
|
+
# One record of an unobserved layout stays in place as ``invalid`` with the error;
|
|
1733
|
+
# the other entities of the drawing are still read
|
|
1734
|
+
from icadkit import LeaderNote2D
|
|
1735
|
+
from icadkit import drawing as drawing_module
|
|
1736
|
+
|
|
1737
|
+
writer = _sheet_writer()
|
|
1738
|
+
writer.add_entities(
|
|
1739
|
+
"XY",
|
|
1740
|
+
[
|
|
1741
|
+
LeaderNote2D(("注記",), (50.0, 50.0), (70.0, 70.0), (100.0, 70.0)),
|
|
1742
|
+
icadkit.Line2D((0.0, 0.0), (10.0, 0.0)),
|
|
1743
|
+
],
|
|
1744
|
+
)
|
|
1745
|
+
_, doc = _entities(writer, (22, 1))
|
|
1746
|
+
|
|
1747
|
+
def broken(*args, **kwargs):
|
|
1748
|
+
raise ValueError("too many values to unpack (expected 3)")
|
|
1749
|
+
|
|
1750
|
+
monkeypatch.setattr(drawing_module, "_note", broken)
|
|
1751
|
+
index = icadkit.read(writer.to_bytes()).read_drawing()
|
|
1752
|
+
assert [e.status for e in index.entities] == ["invalid", "complete"]
|
|
1753
|
+
bad = index.entities[0]
|
|
1754
|
+
assert bad.note is None and bad.primitive is None
|
|
1755
|
+
assert [d.code for d in bad.diagnostics] == ["drawing.entity_error"]
|
|
1756
|
+
assert "ValueError: too many values to unpack" in bad.diagnostics[0].message
|
|
1757
|
+
assert index.status == "invalid"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|