f3d2solidcraft 0.3.2__tar.gz → 0.4.0__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.
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/CHANGELOG.md +24 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/PKG-INFO +3 -2
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/README.md +2 -1
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/docs/guia.md +2 -1
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/pyproject.toml +1 -1
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/__init__.py +1 -1
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/cli.py +5 -1
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/fallback.py +43 -3
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/mappers/__init__.py +3 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/mappers/components.py +190 -49
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/mappers/edges.py +5 -2
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/mappers/params.py +26 -1
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/mappers/revolve.py +3 -1
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/model.py +23 -0
- f3d2solidcraft-0.4.0/src/f3d2solidcraft/paint.py +50 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/reader/__init__.py +30 -11
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/reader/cadir.py +73 -1
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/reader/fusion.py +25 -3
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/report.py +2 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/conftest.py +31 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_components.py +2 -2
- f3d2solidcraft-0.4.0/tests/test_paint.py +178 -0
- f3d2solidcraft-0.4.0/tests/test_parameter_pairing.py +104 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/.github/workflows/ci.yml +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/.github/workflows/release.yml +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/LICENSE +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/docs/media/demo.gif +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/scripts/fetch_cadmpeg.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/scripts/smoke_packaged.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/__main__.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/_vendor/__init__.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/_vendor/ezf3d/LICENSE +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/_vendor/ezf3d/__init__.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/_vendor/ezf3d/container/__init__.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/_vendor/ezf3d/container/archive.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/_vendor/ezf3d/model/__init__.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/_vendor/ezf3d/model/parameters.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/_vendor/ezf3d/model/sketch.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/_vendor/ezf3d/model/timeline.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/_vendor/ezf3d/streams/__init__.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/_vendor/ezf3d/streams/manifest.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/_vendor/ezf3d/streams/primitives.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/_vendor/ezf3d/streams/segment.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/engine.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/geometry.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/mappers/bodies.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/mappers/combine.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/mappers/extrude.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/mappers/faces.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/mappers/loft.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/mappers/outputs.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/mappers/pattern.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/mappers/planes.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/mappers/primitives.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/mappers/records.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/mappers/sheet.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/mappers/shell.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/mappers/sketch.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/mcp.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/oracle.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/pairing.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/reader/locale.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/replay.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/tools.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/verify.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft/visibility.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/__init__.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/__main__.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/engines.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/events.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/opener.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/outcome.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/resources/icon-128.png +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/resources/icon-16.png +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/resources/icon-256.png +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/resources/icon-32.png +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/resources/icon-512.png +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/resources/icon-64.png +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/resources/icon.icns +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/resources/icon.ico +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/resources/icon.svg +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/runner.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/stdio.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/texts.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/window.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/src/f3d2solidcraft_app/winjob.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/app/__init__.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/app/conftest.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/app/test_engines_runner.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/app/test_events_outcome.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/app/test_icon.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/app/test_opener.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/app/test_packaging.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/app/test_stdio.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/app/test_texts.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/app/test_window.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/app/test_winjob.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_bench.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_bezier_spans.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_bodies.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_cli.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_combine.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_condemnation.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_conics.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_declared_edges.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_engine.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_extents.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_faces.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_fetch_cadmpeg.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_geometry.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_inspect_json.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_locations.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_loft.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_mappers.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_mcp.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_naming.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_oracle.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_pairing.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_partial_sketches.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_pattern.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_primitives.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_progress.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_reader.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_replay.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_revolve.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_rollback.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_sheet.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_shell.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_tilted_planes.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_tools.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_trimmed_region.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_unmeasurable.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_unnamed_sketches.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_verify.py +0 -0
- {f3d2solidcraft-0.3.2 → f3d2solidcraft-0.4.0}/tests/test_visibility.py +0 -0
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
- Parameters: every feature now takes its parameters from its own record in the file, even when the two readers
|
|
6
|
+
of the file count the timeline differently. Before, such a design got no parameter on any feature; now its
|
|
7
|
+
extrude distances and sketch dimensions are linked to their parameters in the SolidCraft timeline too. Where
|
|
8
|
+
those features' bodies still come in as imported bodies, changing the parameter updates the timeline but does
|
|
9
|
+
not move that geometry yet. The report counts the features that could not be paired (`unpaired_features`)
|
|
10
|
+
instead of a general "timeline mismatch" warning.
|
|
11
|
+
- Fillet radii, chamfer distances and revolve angles follow the parameter that drives them in Fusion, when the
|
|
12
|
+
file names exactly one and its value matches.
|
|
13
|
+
- Components: the saved design shows Fusion's component tree. A part the converter could not rebuild arrives with
|
|
14
|
+
Fusion's name and every placement, without an empty copy beside it, and the empty components the conversion
|
|
15
|
+
used to leave are removed. The container of the imported geometry is now called "Imported from Fusion". Known
|
|
16
|
+
limit: when the import arrives with the assembly flattened (seen in some `.f3z` packages), its bodies stay at
|
|
17
|
+
the level of "Imported from Fusion" and nested parts may carry generated names.
|
|
18
|
+
- Colours: the bodies rebuilt as native SolidCraft features take the colour Fusion binds to them. Imported bodies
|
|
19
|
+
already kept theirs. Per-face colours are not applied yet: a rebuilt body gets its body colour only, and the
|
|
20
|
+
report warns when Fusion colours single faces of it.
|
|
21
|
+
- A rebuilt body that comes out identical to the original is kept as a native body instead of being replaced by
|
|
22
|
+
the imported one.
|
|
23
|
+
- Known limits: some empty components with repeated names can remain under "Imported from Fusion". They are the
|
|
24
|
+
import's own definitions whose bodies moved into the design's component; SolidCraft refuses to delete them
|
|
25
|
+
because it recorded that body transfer. They hold no geometry and change nothing but the tree.
|
|
26
|
+
|
|
3
27
|
## 0.3.2
|
|
4
28
|
|
|
5
29
|
- Windows app: loading a file failed with "Could not read the file: exit code 0", whatever the file. The
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: f3d2solidcraft
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Convert Autodesk Fusion .f3d/.f3z designs into editable SolidCraft designs
|
|
5
5
|
Project-URL: Homepage, https://github.com/cristiancarterm/f3d2solidcraft
|
|
6
6
|
Project-URL: Issues, https://github.com/cristiancarterm/f3d2solidcraft/issues
|
|
@@ -155,7 +155,8 @@ design.f3d
|
|
|
155
155
|
- `exact`: rebuilt from what the file says.
|
|
156
156
|
- `inferred`: rebuilt too, but with a choice the file does not record (which profiles an extrude used, which edges a
|
|
157
157
|
fillet rounded), measured against the original solid. Its warnings say what was chosen and how clearly.
|
|
158
|
-
- `fallback`: not rebuilt; its body comes in as an imported body
|
|
158
|
+
- `fallback`: not rebuilt; its body comes in as an imported body, unless the rebuilt body already matches the
|
|
159
|
+
original, in which case it is kept native.
|
|
159
160
|
- `failed`: not rebuilt, with no body to fall back to (a construction plane, for example).
|
|
160
161
|
- `skipped`: suppressed in Fusion.
|
|
161
162
|
- `bodies: N native, M imported`: where the final bodies come from.
|
|
@@ -126,7 +126,8 @@ design.f3d
|
|
|
126
126
|
- `exact`: rebuilt from what the file says.
|
|
127
127
|
- `inferred`: rebuilt too, but with a choice the file does not record (which profiles an extrude used, which edges a
|
|
128
128
|
fillet rounded), measured against the original solid. Its warnings say what was chosen and how clearly.
|
|
129
|
-
- `fallback`: not rebuilt; its body comes in as an imported body
|
|
129
|
+
- `fallback`: not rebuilt; its body comes in as an imported body, unless the rebuilt body already matches the
|
|
130
|
+
original, in which case it is kept native.
|
|
130
131
|
- `failed`: not rebuilt, with no body to fall back to (a construction plane, for example).
|
|
131
132
|
- `skipped`: suppressed in Fusion.
|
|
132
133
|
- `bodies: N native, M imported`: where the final bodies come from.
|
|
@@ -137,7 +137,8 @@ Cómo leer el resumen:
|
|
|
137
137
|
- `inferred`: también reconstruida, pero con una elección que el archivo no registra (qué perfiles usó una
|
|
138
138
|
extrusión, qué aristas redondeó un empalme), medida contra el sólido original. Sus avisos indican qué se eligió y
|
|
139
139
|
con qué claridad.
|
|
140
|
-
- `fallback`: no se reconstruyó; su cuerpo llega como cuerpo importado
|
|
140
|
+
- `fallback`: no se reconstruyó; su cuerpo llega como cuerpo importado, salvo que el cuerpo reconstruido ya
|
|
141
|
+
coincida con el original; en ese caso se conserva nativo.
|
|
141
142
|
- `failed`: no se reconstruyó y no tenía un cuerpo que importar (por ejemplo, un plano de construcción).
|
|
142
143
|
- `skipped`: estaba suprimida en Fusion.
|
|
143
144
|
- `bodies: N native, M imported`: de dónde vienen los cuerpos finales.
|
|
@@ -59,7 +59,7 @@ packages = ["src/f3d2solidcraft", "src/f3d2solidcraft_app"]
|
|
|
59
59
|
[tool.briefcase]
|
|
60
60
|
project_name = "f3d2solidcraft"
|
|
61
61
|
bundle = "cl.mitocondria"
|
|
62
|
-
version = "0.
|
|
62
|
+
version = "0.4.0" # the package's own version: tests/app/test_packaging.py keeps the two equal
|
|
63
63
|
url = "https://github.com/cristiancarterm/f3d2solidcraft"
|
|
64
64
|
# The license comes from [project] (PEP 639: `license` + `license-files`); Briefcase refuses both forms.
|
|
65
65
|
author = "Cristián Carter"
|
|
@@ -22,6 +22,7 @@ from f3d2solidcraft.fallback import apply_fallback, name_bodies, original_step
|
|
|
22
22
|
from f3d2solidcraft.mappers import MAPPERS
|
|
23
23
|
from f3d2solidcraft.mappers.components import reconcile_components
|
|
24
24
|
from f3d2solidcraft.oracle import Oracle, OracleUnavailable, PlacementsUnmeasurable
|
|
25
|
+
from f3d2solidcraft.paint import paint_native
|
|
25
26
|
from f3d2solidcraft.reader import read_design
|
|
26
27
|
from f3d2solidcraft.replay import replay
|
|
27
28
|
from f3d2solidcraft.report import build_report, summary
|
|
@@ -87,11 +88,14 @@ def _in_engine(
|
|
|
87
88
|
# The reference the oracle already read *is* the original, so the verification
|
|
88
89
|
# takes its view of it from there instead of opening the STEP again at the end.
|
|
89
90
|
original = _reference_reading(oracle)
|
|
90
|
-
fallback_warnings = step_warnings + oracle_warnings + apply_fallback(ctx, result, step)
|
|
91
|
+
fallback_warnings = step_warnings + oracle_warnings + apply_fallback(ctx, result, step, original)
|
|
91
92
|
# Right after the import, so everything below reads the names the design gives its
|
|
92
93
|
# bodies rather than the STEP export's: the rebuild check and the measurement the
|
|
93
94
|
# verification reports, the component reconciliation and the visibility replay.
|
|
94
95
|
fallback_warnings += name_bodies(ctx, result)
|
|
96
|
+
# The bodies that stayed native lost nothing to the import but their colour, which the
|
|
97
|
+
# import's STEP carries and the replay does not: put back the one Fusion binds to them.
|
|
98
|
+
fallback_warnings += paint_native(ctx, result)
|
|
95
99
|
rebuild_parameter = driving_parameter(ctx, result)
|
|
96
100
|
rebuild_error = check_rebuild(ctx, result)
|
|
97
101
|
# The placements the measurement below stands for, counted off the component graph: one
|
|
@@ -7,6 +7,7 @@ from pathlib import Path
|
|
|
7
7
|
|
|
8
8
|
from f3d2solidcraft.engine import CommandRefused
|
|
9
9
|
from f3d2solidcraft.mappers import Context
|
|
10
|
+
from f3d2solidcraft.mappers.components import IMPORT_HOLDER
|
|
10
11
|
from f3d2solidcraft.pairing import declared_name
|
|
11
12
|
from f3d2solidcraft.replay import ReplayResult
|
|
12
13
|
from f3d2solidcraft.tools import ToolFailed, run_tool
|
|
@@ -99,10 +100,46 @@ def same_body(
|
|
|
99
100
|
return all(abs(x - y) <= com_abs for x, y in zip(here, there))
|
|
100
101
|
|
|
101
102
|
|
|
102
|
-
def
|
|
103
|
+
def identical_to_original(ctx: Context, result: ReplayResult, reference: list[dict] | None) -> set[str]:
|
|
104
|
+
"""The bodies the replay left unfinished that are, measured, the very body of the original.
|
|
105
|
+
|
|
106
|
+
A body is condemned to the fallback when a feature that shapes it could not be rebuilt, and that
|
|
107
|
+
says nothing about whether the body came out right anyway. Measured over the corpus's 13 such
|
|
108
|
+
bodies, one did: `corpus-02`'s `Body2`, 6654.503 mm³ and 14 faces on both sides. Removing
|
|
109
|
+
it threw a native body away for an imported copy of itself (spec 0.4, item 4).
|
|
110
|
+
|
|
111
|
+
The original is the oracle's reading, and which of its bodies to compare with is the one
|
|
112
|
+
`pairing.declared_name` names for the Fusion id — a body without one is not compared, because
|
|
113
|
+
against every body it could match the wrong one. The comparison is `same_body` with faces.
|
|
114
|
+
"""
|
|
115
|
+
if not reference:
|
|
116
|
+
return set()
|
|
117
|
+
by_name = {r["name"]: r for r in reference}
|
|
118
|
+
standing = set(ctx.engine.body_names())
|
|
119
|
+
candidates = {}
|
|
120
|
+
for body_id in sorted(result.fallback_bodies):
|
|
121
|
+
name = ctx.body_names.get(body_id)
|
|
122
|
+
declared = declared_name(ctx.design, body_id, list(by_name))
|
|
123
|
+
if name in standing and declared is not None:
|
|
124
|
+
candidates[name] = by_name[declared]
|
|
125
|
+
if not candidates:
|
|
126
|
+
return set()
|
|
127
|
+
readings = {b["name"]: b for b in ctx.engine.body_readings(sorted(candidates))}
|
|
128
|
+
return {
|
|
129
|
+
name
|
|
130
|
+
for name, original in candidates.items()
|
|
131
|
+
if name in readings and same_body(readings[name], original, faces=True)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def apply_fallback(
|
|
136
|
+
ctx: Context, result: ReplayResult, step: Path, reference: list[dict] | None = None
|
|
137
|
+
) -> list[str]:
|
|
103
138
|
"""Swap the bodies the replay could not finish for the original B-rep; record what was imported.
|
|
104
139
|
|
|
105
140
|
The names of the imported bodies that stay land in ``result.imported_bodies``; returns warnings.
|
|
141
|
+
`reference` is the oracle's reading of the original: a body it says is already identical to its
|
|
142
|
+
original stays native, and the import's copy of it goes as a duplicate.
|
|
106
143
|
"""
|
|
107
144
|
if not result.fallback_bodies:
|
|
108
145
|
return []
|
|
@@ -111,13 +148,16 @@ def apply_fallback(ctx: Context, result: ReplayResult, step: Path) -> list[str]:
|
|
|
111
148
|
# import brings it back like any other. This said the opposite and was simply false.
|
|
112
149
|
warnings: list[str] = []
|
|
113
150
|
present = set(engine.body_names())
|
|
114
|
-
|
|
151
|
+
kept_native = identical_to_original(ctx, result, reference)
|
|
152
|
+
partial = sorted(
|
|
153
|
+
({ctx.body_names[b] for b in result.fallback_bodies if b in ctx.body_names} & present) - kept_native
|
|
154
|
+
)
|
|
115
155
|
if partial:
|
|
116
156
|
engine.execute("solid.remove", {"bodies": partial})
|
|
117
157
|
kept = engine.body_readings()
|
|
118
158
|
kept_names = {b["name"] for b in kept}
|
|
119
159
|
try:
|
|
120
|
-
engine.execute("file.insert_step", {"path": str(step), "name":
|
|
160
|
+
engine.execute("file.insert_step", {"path": str(step), "name": IMPORT_HOLDER})
|
|
121
161
|
except CommandRefused as exc:
|
|
122
162
|
# This one call *is* the safety net, and it was the only unprotected one in the path, so a
|
|
123
163
|
# refusal here ended the whole conversion with the engine's error and no report at all.
|
|
@@ -72,6 +72,9 @@ class Context:
|
|
|
72
72
|
# The geometry is there for whoever opens the design; what must not happen is a feature
|
|
73
73
|
# building a body out of a profile that is missing a piece (spec section 87).
|
|
74
74
|
partial_sketches: set[str] = field(default_factory=set)
|
|
75
|
+
# Fusion parameter -> (the value the engine computed for it, its unit), as `parameters.add`
|
|
76
|
+
# answered. What a mapper checks before it lets a feature follow a parameter (`params.follows`).
|
|
77
|
+
param_values: dict[str, tuple[float, str]] = field(default_factory=dict)
|
|
75
78
|
|
|
76
79
|
|
|
77
80
|
Mapper = Callable[[Feature, Context], list[str] | tuple[str, list[str]]]
|
|
@@ -28,6 +28,9 @@ from f3d2solidcraft.mappers import Context
|
|
|
28
28
|
from f3d2solidcraft.model import Component, Feature, Frame, Occurrence, Vec3
|
|
29
29
|
|
|
30
30
|
ROOT = "root"
|
|
31
|
+
# The component the fallback import lands in, under the design's root, and what the user sees it
|
|
32
|
+
# called. Once named `Fusion fallback`, which read as an error in the file the user opens.
|
|
33
|
+
IMPORT_HOLDER = "Imported from Fusion"
|
|
31
34
|
|
|
32
35
|
# How far a rotation term may sit from the matrix the file states, and a translation from its
|
|
33
36
|
# millimetres, for the placement to count as the one the file asked for. The engine answers in
|
|
@@ -432,63 +435,217 @@ def _placements(cid: object, by_id: dict, memo: dict[object, int]) -> int:
|
|
|
432
435
|
return memo[cid]
|
|
433
436
|
|
|
434
437
|
|
|
438
|
+
def _unlock(ctx: Context, holder: object, unlocked: set[object]) -> list[str]:
|
|
439
|
+
"""Unlock the import's holder once, so its contents can leave it; returns warnings."""
|
|
440
|
+
if holder in unlocked:
|
|
441
|
+
return []
|
|
442
|
+
unlocked.add(holder)
|
|
443
|
+
try:
|
|
444
|
+
# The import lands as one rigid group; its bodies cannot leave it until unlocked.
|
|
445
|
+
ctx.engine.execute("component.unlock", {"component": holder})
|
|
446
|
+
except CommandRefused as exc:
|
|
447
|
+
# A refusal here is not a reason to leave the bodies in the import's own holder, and it used
|
|
448
|
+
# to be: the move was skipped outright. Measured on a real design with no feature history at
|
|
449
|
+
# all (every body imported, one unnamed component), the engine refuses with `nothing holds
|
|
450
|
+
# this component's contents together` — there was no lock to undo.
|
|
451
|
+
#
|
|
452
|
+
# So the move is tried anyway and the engine decides. A component that really is locked
|
|
453
|
+
# refuses the move too, and that refusal is the one worth reporting; this one is only a note.
|
|
454
|
+
return [f"the imported bodies were not unlocked first: {exc.message}"]
|
|
455
|
+
return []
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
def _import_holder(tree: list[dict]) -> dict | None:
|
|
459
|
+
"""The component the fallback import made directly under the design's root, if there is one."""
|
|
460
|
+
root = next((c["id"] for c in tree if c.get("parent") is None), None)
|
|
461
|
+
return next((c for c in tree if c.get("name") == IMPORT_HOLDER and c.get("parent") == root), None)
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
def _theirs(tree: list[dict], holder: dict | None) -> set[object]:
|
|
465
|
+
"""The import's own components: its holder and every component placed under it."""
|
|
466
|
+
if holder is None:
|
|
467
|
+
return set()
|
|
468
|
+
part_of = {occ["id"]: c["id"] for c in tree for occ in c.get("occurrences") or []}
|
|
469
|
+
by_id = {c["id"]: c for c in tree}
|
|
470
|
+
found, pending = set(), [holder["id"]]
|
|
471
|
+
while pending:
|
|
472
|
+
cid = pending.pop()
|
|
473
|
+
if cid not in found:
|
|
474
|
+
found.add(cid)
|
|
475
|
+
pending += [part_of[o] for o in by_id[cid].get("children") or [] if o in part_of]
|
|
476
|
+
return found
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
def _promote(
|
|
480
|
+
ctx: Context, tree: list[dict], holder: dict, theirs: set[object], unlocked: set[object]
|
|
481
|
+
) -> list[str]:
|
|
482
|
+
"""Hand each top-level part of the import to the design where ours holds nothing; returns warnings.
|
|
483
|
+
|
|
484
|
+
The import already rebuilds Fusion's tree for what it brings: one definition per part, one
|
|
485
|
+
occurrence per placement, Fusion's names. The replay builds one component of ours per Fusion
|
|
486
|
+
occurrence, and where no feature was rebuilt into it, ours is empty scaffolding beside the
|
|
487
|
+
import's real one — measured on a third-party board, 98 of its 130 components. So where every
|
|
488
|
+
component of ours by that name (and everything under it) holds no body, feature, sketch or
|
|
489
|
+
construction geometry, ours go and the import's occurrence moves under the design's root in
|
|
490
|
+
their place: `occurrence.reparent` keeps its world position, and it arrives with every copy it
|
|
491
|
+
places.
|
|
492
|
+
|
|
493
|
+
Where ours holds native work, the import's part is left for `_move_imported_bodies`, which is the
|
|
494
|
+
path every body took before. A part with no component of ours by that name is promoted too:
|
|
495
|
+
there is nothing of ours for it to join.
|
|
496
|
+
"""
|
|
497
|
+
by_id = {c["id"]: c for c in tree}
|
|
498
|
+
part_of = {occ["id"]: c for c in tree for occ in c.get("occurrences") or []}
|
|
499
|
+
root = holder["parent"]
|
|
500
|
+
ours: dict[str, list[object]] = {}
|
|
501
|
+
for component in tree:
|
|
502
|
+
if component.get("parent") == root and component["id"] not in theirs:
|
|
503
|
+
ours.setdefault(str(component.get("name")), []).append(component["id"])
|
|
504
|
+
|
|
505
|
+
def native(cid: object) -> bool:
|
|
506
|
+
component = by_id[cid]
|
|
507
|
+
own = any(component.get(key) for key in ("bodies", "features", "sketches", "construction"))
|
|
508
|
+
return own or any(native(part_of[o]["id"]) for o in component.get("children") or [])
|
|
509
|
+
|
|
510
|
+
warnings: list[str] = []
|
|
511
|
+
gone: set[object] = set()
|
|
512
|
+
for occurrence in holder.get("children") or []:
|
|
513
|
+
name = str(part_of[occurrence].get("name"))
|
|
514
|
+
mine = ours.get(name, [])
|
|
515
|
+
if any(native(cid) for cid in mine):
|
|
516
|
+
continue
|
|
517
|
+
try:
|
|
518
|
+
for cid in mine:
|
|
519
|
+
if cid not in gone:
|
|
520
|
+
ctx.engine.execute("component.delete", {"component": cid})
|
|
521
|
+
gone.add(cid)
|
|
522
|
+
except CommandRefused as exc:
|
|
523
|
+
warnings.append(f"component {name} kept as built: {exc.message}")
|
|
524
|
+
continue
|
|
525
|
+
warnings += _unlock(ctx, holder["id"], unlocked)
|
|
526
|
+
try:
|
|
527
|
+
ctx.engine.execute("occurrence.reparent", {"occurrence": occurrence, "parent": root})
|
|
528
|
+
except CommandRefused as exc:
|
|
529
|
+
warnings.append(f"{name} stays in the import: {exc.message}")
|
|
530
|
+
ctx.component_ids = {key: value for key, value in ctx.component_ids.items() if value not in gone}
|
|
531
|
+
return warnings
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
def _drop_empty(ctx: Context, theirs: set[object]) -> None:
|
|
535
|
+
"""Delete the components of ours left with nothing in them, until none is left.
|
|
536
|
+
|
|
537
|
+
Ours is every component but the root and the import's: `ctx.component_ids` keeps one component
|
|
538
|
+
per Fusion component and the replay makes one per placement, so it does not list them all. A
|
|
539
|
+
component the engine will not delete stays, and is not a failure.
|
|
540
|
+
|
|
541
|
+
A component that is empty **in Fusion too** stays: the designer left it there, and the tree
|
|
542
|
+
should read like Fusion's (Cristián's decision, 2026-11-18). Only scaffolding goes, the
|
|
543
|
+
components whose content the import holds or `_promote` took over. Empty in Fusion means a named
|
|
544
|
+
component with no bodies, no sketches and no occurrence placed inside it. No corpus design has
|
|
545
|
+
one, so this branch is guarded by reading, not by a corpus test.
|
|
546
|
+
"""
|
|
547
|
+
placed_in = {o.parent for o in ctx.design.occurrences if o.parent is not None}
|
|
548
|
+
holders = {o.component for o in ctx.design.occurrences if o.id in placed_in}
|
|
549
|
+
empty_in_fusion = {
|
|
550
|
+
c.name
|
|
551
|
+
for c in ctx.design.components.values()
|
|
552
|
+
if c.name and not c.bodies and not c.sketches and c.id not in holders
|
|
553
|
+
}
|
|
554
|
+
tried: set[object] = set(theirs)
|
|
555
|
+
gone: set[object] = set()
|
|
556
|
+
while True:
|
|
557
|
+
tree = ctx.engine.execute("component.list", {"compact": True, "bodies": True})["components"]
|
|
558
|
+
empty = [
|
|
559
|
+
c["id"]
|
|
560
|
+
for c in tree
|
|
561
|
+
if c.get("parent") is not None
|
|
562
|
+
and c["id"] not in tried
|
|
563
|
+
and c.get("name") not in empty_in_fusion
|
|
564
|
+
and not any(c.get(key) for key in ("bodies", "children", "features", "sketches", "construction"))
|
|
565
|
+
]
|
|
566
|
+
if not empty:
|
|
567
|
+
break
|
|
568
|
+
for cid in empty:
|
|
569
|
+
tried.add(cid)
|
|
570
|
+
try:
|
|
571
|
+
ctx.engine.execute("component.delete", {"component": cid})
|
|
572
|
+
except CommandRefused:
|
|
573
|
+
continue
|
|
574
|
+
gone.add(cid)
|
|
575
|
+
ctx.component_ids = {key: value for key, value in ctx.component_ids.items() if value not in gone}
|
|
576
|
+
|
|
577
|
+
|
|
435
578
|
def reconcile_components(ctx: Context, imported_bodies: list[str]) -> list[str]:
|
|
436
|
-
"""
|
|
579
|
+
"""Give the imported bodies Fusion's component tree; returns warnings.
|
|
437
580
|
|
|
438
581
|
`cadmpeg convert` writes the assembly structure into the STEP and SolidCraft's importer
|
|
439
|
-
rebuilds it, so the imported bodies arrive inside components carrying Fusion's own names
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
582
|
+
rebuilds it, so the imported bodies arrive inside components carrying Fusion's own names,
|
|
583
|
+
nesting and placements. Three steps, in this order (spec 0.4, item 2):
|
|
584
|
+
|
|
585
|
+
1. `_promote`: a top-level part of the import whose components of ours hold no native work
|
|
586
|
+
replaces them, every placement included.
|
|
587
|
+
2. `_move_imported_bodies`: what is left in the import joins the components of ours that do
|
|
588
|
+
hold native work, as before 0.4.
|
|
589
|
+
3. `_drop_empty`: the components of ours that ended up with nothing in them go.
|
|
590
|
+
|
|
591
|
+
The import's holder itself stays, under the name `IMPORT_HOLDER`: the engine does not delete it
|
|
592
|
+
and its Import feature is in the timeline either way.
|
|
593
|
+
"""
|
|
594
|
+
if not imported_bodies:
|
|
595
|
+
return []
|
|
596
|
+
tree = ctx.engine.execute("component.list", {"compact": True, "bodies": True})["components"]
|
|
597
|
+
holder = _import_holder(tree)
|
|
598
|
+
theirs = _theirs(tree, holder)
|
|
599
|
+
unlocked: set[object] = set()
|
|
600
|
+
warnings = _promote(ctx, tree, holder, theirs, unlocked) if holder is not None else []
|
|
601
|
+
warnings += _move_imported_bodies(ctx, set(imported_bodies), unlocked)
|
|
602
|
+
_drop_empty(ctx, theirs)
|
|
603
|
+
return warnings
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
def _move_imported_bodies(ctx: Context, imported: set[str], unlocked: set[object]) -> list[str]:
|
|
607
|
+
"""Move the imported bodies still in the import into the components Fusion owns them in.
|
|
608
|
+
|
|
609
|
+
**A design that declares no components at all is still reconciled.** Its bodies used to be left
|
|
610
|
+
in the import's holder — a name of this converter's own, in the file the user opens. The file
|
|
611
|
+
attributing no body to a named component is the case the loop below answers with the design
|
|
612
|
+
root. Measured on `corpus-11` and `corpus-10`, the two corpus designs
|
|
613
|
+
with no component tree and every body imported.
|
|
455
614
|
|
|
456
615
|
**A part placed more than once stays in the import's structure.** The import places a
|
|
457
616
|
definition as many times as the original does, and the replay builds one component per Fusion
|
|
458
617
|
occurrence, so there is no one component its bodies could go to: moving them into any single
|
|
459
618
|
one of ours left one placement where the original has N. Measured on a third-party board of 302
|
|
460
|
-
placements of 43 definitions
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
placed more than once.
|
|
619
|
+
placements of 43 definitions, the saved file held 43 bodies. So a component the import places
|
|
620
|
+
more than once, counting the placements of every component above it up to the import's holder,
|
|
621
|
+
keeps its bodies, and one aggregated warning says how many parts stayed.
|
|
622
|
+
|
|
623
|
+
Only bodies still inside the import's holder are moved: a part `_promote` already handed to the
|
|
624
|
+
design is in its place.
|
|
467
625
|
"""
|
|
468
|
-
if not imported_bodies:
|
|
469
|
-
return []
|
|
470
626
|
warnings: list[str] = []
|
|
471
627
|
tree = ctx.engine.execute("component.list", {"compact": True, "bodies": True})["components"]
|
|
472
628
|
by_id = {c["id"]: c for c in tree}
|
|
629
|
+
import_holder = _import_holder(tree)
|
|
473
630
|
ours = _our_paths(ctx)
|
|
474
|
-
imported = set(imported_bodies)
|
|
475
631
|
attributed = any(c.bodies for c in ctx.design.components.values() if c.name)
|
|
476
|
-
unlocked: set[object] = set()
|
|
477
632
|
repeated: list[tuple[int, int]] = [] # (bodies, placements) of each part left in the import
|
|
478
633
|
placed: dict[object, int] = {}
|
|
479
634
|
for component in tree:
|
|
480
635
|
held = [b for b in component.get("bodies") or [] if b in imported]
|
|
481
636
|
if not held:
|
|
482
637
|
continue
|
|
483
|
-
times = _placements(component["id"], by_id, placed)
|
|
484
|
-
if times > 1:
|
|
485
|
-
repeated.append((len(held), times))
|
|
486
|
-
continue
|
|
487
638
|
names, walk, holder = [], component, component
|
|
488
639
|
while walk is not None and walk.get("parent") is not None:
|
|
489
640
|
holder = walk
|
|
490
641
|
names.append(str(walk.get("name")))
|
|
491
642
|
walk = by_id.get(walk["parent"])
|
|
643
|
+
if import_holder is None or holder["id"] != import_holder["id"]:
|
|
644
|
+
continue # promoted, or never in the import: already where the design has it
|
|
645
|
+
times = _placements(component["id"], by_id, placed)
|
|
646
|
+
if times > 1:
|
|
647
|
+
repeated.append((len(held), times))
|
|
648
|
+
continue
|
|
492
649
|
path = tuple(reversed(names[:-1])) # the holder's own name is the import's, not Fusion's
|
|
493
650
|
if not path:
|
|
494
651
|
# Bodies at the holder's own level carry no component. They are the design root's when
|
|
@@ -511,23 +668,7 @@ def reconcile_components(ctx: Context, imported_bodies: list[str]) -> list[str]:
|
|
|
511
668
|
"design; they stay where the import put them"
|
|
512
669
|
)
|
|
513
670
|
continue
|
|
514
|
-
|
|
515
|
-
unlocked.add(holder["id"])
|
|
516
|
-
try:
|
|
517
|
-
# The import lands as one rigid group; its bodies cannot leave it until unlocked.
|
|
518
|
-
ctx.engine.execute("component.unlock", {"component": holder["id"]})
|
|
519
|
-
except CommandRefused as exc:
|
|
520
|
-
# A refusal here is not a reason to leave the bodies in the import's own holder, and
|
|
521
|
-
# it used to be: the move was skipped outright. Measured on a real design with no
|
|
522
|
-
# feature history at all (every body imported, one unnamed component), the engine
|
|
523
|
-
# refuses with `nothing holds this component's contents together` — there was no
|
|
524
|
-
# lock to undo — and the bodies stayed in `Fusion fallback`, a name of this
|
|
525
|
-
# converter's own, in the file the user opens.
|
|
526
|
-
#
|
|
527
|
-
# So the move is tried anyway and `component.move_bodies` decides. A component that
|
|
528
|
-
# really is locked refuses the move too, and that refusal is the one worth
|
|
529
|
-
# reporting; this one is only a note.
|
|
530
|
-
warnings.append(f"the imported bodies were not unlocked first: {exc.message}")
|
|
671
|
+
warnings += _unlock(ctx, holder["id"], unlocked)
|
|
531
672
|
try:
|
|
532
673
|
ctx.engine.execute("component.move_bodies", {"bodies": held, "component": target})
|
|
533
674
|
except CommandRefused as exc:
|
|
@@ -37,6 +37,7 @@ from itertools import combinations
|
|
|
37
37
|
from f3d2solidcraft.engine import CommandRefused, EngineError, rolled_back
|
|
38
38
|
from f3d2solidcraft.mappers import Context, Unsupported, definition, register
|
|
39
39
|
from f3d2solidcraft.mappers.components import placed_point
|
|
40
|
+
from f3d2solidcraft.mappers.params import follows
|
|
40
41
|
from f3d2solidcraft.model import Feature
|
|
41
42
|
from f3d2solidcraft.oracle import (
|
|
42
43
|
OracleUnavailable,
|
|
@@ -86,12 +87,14 @@ def _apply(ctx: Context, feature: Feature, body: str, points: list) -> None:
|
|
|
86
87
|
op = feature.edge_op
|
|
87
88
|
params = {"edges": list(points), "body": body}
|
|
88
89
|
if op.kind == "fillet":
|
|
89
|
-
ctx
|
|
90
|
+
radius = follows(ctx, feature, "Radius", op.value, "mm") or f"{op.value} mm"
|
|
91
|
+
ctx.engine.execute("solid.fillet", {**params, "radius": radius})
|
|
90
92
|
return
|
|
91
93
|
if op.angle_rad is not None:
|
|
92
94
|
# angle_rad is an angle in radians, not a second distance: not mapped in M1.
|
|
93
95
|
raise Unsupported("two-distance chamfer")
|
|
94
|
-
ctx
|
|
96
|
+
distance = follows(ctx, feature, "Distance", op.value, "mm") or f"{op.value} mm"
|
|
97
|
+
ctx.engine.execute("solid.chamfer", {**params, "distance": distance})
|
|
95
98
|
|
|
96
99
|
|
|
97
100
|
def _edge_candidates(ctx: Context, body: str, oracle) -> list[dict]:
|
|
@@ -6,7 +6,7 @@ import re
|
|
|
6
6
|
|
|
7
7
|
from f3d2solidcraft.engine import CommandRefused
|
|
8
8
|
from f3d2solidcraft.mappers import Context
|
|
9
|
-
from f3d2solidcraft.model import Parameter
|
|
9
|
+
from f3d2solidcraft.model import Feature, Parameter
|
|
10
10
|
|
|
11
11
|
_MODEL_NAME = re.compile(r"^d\d+$")
|
|
12
12
|
_WORD = re.compile(r"\b[A-Za-z_][A-Za-z0-9_]*\b")
|
|
@@ -126,9 +126,34 @@ def add_parameters(ctx: Context) -> list[str]:
|
|
|
126
126
|
warnings.append(wrong)
|
|
127
127
|
ctx.param_names[p.name] = names[p.name]
|
|
128
128
|
ctx.param_expressions[p.name] = expression
|
|
129
|
+
if isinstance(created, dict) and isinstance(created.get("value"), int | float):
|
|
130
|
+
ctx.param_values[p.name] = (float(created["value"]), str(created.get("unit")))
|
|
129
131
|
pending.remove(p)
|
|
130
132
|
errors.pop(p.name, None)
|
|
131
133
|
progressed = True
|
|
132
134
|
if not progressed:
|
|
133
135
|
break
|
|
134
136
|
return warnings + [f"parameter {name} not created: {msg}" for name, msg in errors.items()]
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def follows(ctx: Context, feature: Feature, role: str, wanted: float, unit: str) -> str | None:
|
|
140
|
+
"""An expression of this feature's own parameter that comes to `wanted`, or None to keep the number.
|
|
141
|
+
|
|
142
|
+
Taken only where the file is unambiguous: exactly one of the parameters the feature owns fills
|
|
143
|
+
`role`, it was created in the design, and the value the engine computed for it is `wanted` in
|
|
144
|
+
`unit` — or its opposite, which a reversed feature carries as a sign (`-fusion_d30`). Anything
|
|
145
|
+
else keeps the number the file resolved, so a feature never follows a parameter it does not own.
|
|
146
|
+
"""
|
|
147
|
+
owned = [p for p in ctx.design.parameters if p.name in feature.parameters and p.role == role]
|
|
148
|
+
if len(owned) != 1:
|
|
149
|
+
return None
|
|
150
|
+
name = ctx.param_names.get(owned[0].name)
|
|
151
|
+
computed = ctx.param_values.get(owned[0].name)
|
|
152
|
+
if name is None or computed is None or computed[1] != unit:
|
|
153
|
+
return None
|
|
154
|
+
tolerance = max(_AGREEMENT, 1e-9 * abs(wanted))
|
|
155
|
+
if abs(computed[0] - wanted) <= tolerance:
|
|
156
|
+
return name
|
|
157
|
+
if abs(computed[0] + wanted) <= tolerance:
|
|
158
|
+
return f"-{name}"
|
|
159
|
+
return None
|
|
@@ -7,6 +7,7 @@ import math
|
|
|
7
7
|
from f3d2solidcraft.geometry import _cross
|
|
8
8
|
from f3d2solidcraft.mappers import JOIN_TOUCHING, Context, Unsupported, definition, register
|
|
9
9
|
from f3d2solidcraft.mappers.outputs import name_outputs, no_target
|
|
10
|
+
from f3d2solidcraft.mappers.params import follows
|
|
10
11
|
from f3d2solidcraft.model import Feature, Frame, Vec3
|
|
11
12
|
|
|
12
13
|
_OPERATIONS = {"new_body": "new", "join": "join", "cut": "cut", "intersect": "intersect"}
|
|
@@ -121,7 +122,8 @@ def map_revolve(feature: Feature, ctx: Context) -> list[str]:
|
|
|
121
122
|
# every other profile kind spends measurements on does not arise here. `exact`.
|
|
122
123
|
"profiles": "all",
|
|
123
124
|
"axis": axis,
|
|
124
|
-
"angle":
|
|
125
|
+
"angle": follows(ctx, feature, "AlongAngle", math.degrees(rev.angle_rad) * sign, "deg")
|
|
126
|
+
or f"{math.degrees(rev.angle_rad) * sign:.10g} deg",
|
|
125
127
|
"operation": operation,
|
|
126
128
|
"name": feature.name,
|
|
127
129
|
"touching": JOIN_TOUCHING,
|
|
@@ -421,6 +421,11 @@ class Feature:
|
|
|
421
421
|
shell: Shell | None = None
|
|
422
422
|
primitive: dict | None = None
|
|
423
423
|
parameters: tuple[str, ...] = ()
|
|
424
|
+
# The object id of the timeline item that places this feature, read off the end of its cadmpeg
|
|
425
|
+
# id (`…:Extrude3:1234`). It is what pairs the feature with the record ezf3d reads its parameters
|
|
426
|
+
# from: that record is the object right before the item. None for a feature of a merged `.f3z`
|
|
427
|
+
# member, whose id is an `f3d:xref/…` and whose item lives in another member's stream.
|
|
428
|
+
item: int | None = None
|
|
424
429
|
|
|
425
430
|
|
|
426
431
|
@dataclass(frozen=True)
|
|
@@ -434,6 +439,20 @@ class Body:
|
|
|
434
439
|
name: str | None = None
|
|
435
440
|
|
|
436
441
|
|
|
442
|
+
@dataclass(frozen=True)
|
|
443
|
+
class Paint:
|
|
444
|
+
"""A colour Fusion binds to a body, or to one face of it (spec 0.4, item 3).
|
|
445
|
+
|
|
446
|
+
`rgba` is the appearance's `base_color`, each channel 0..1. A face's own colour carries the face
|
|
447
|
+
id: `appearance.assign` picks a face by a point, and the file gives none for a face, so a face
|
|
448
|
+
colour is read and reported but not applied (see `paint.paint_native`).
|
|
449
|
+
"""
|
|
450
|
+
|
|
451
|
+
body: str # the Fusion body id
|
|
452
|
+
rgba: tuple[float, float, float, float]
|
|
453
|
+
face: str | None = None # the Fusion face id, for a face's own colour
|
|
454
|
+
|
|
455
|
+
|
|
437
456
|
@dataclass(frozen=True)
|
|
438
457
|
class Component:
|
|
439
458
|
"""A Fusion component: the design's own parts, each owning bodies and sketches.
|
|
@@ -501,3 +520,7 @@ class Design:
|
|
|
501
520
|
warnings: list[str] = field(default_factory=list)
|
|
502
521
|
components: dict[str, Component] = field(default_factory=dict)
|
|
503
522
|
occurrences: list[Occurrence] = field(default_factory=list)
|
|
523
|
+
# The features no parameter record could be paired with, by name: they carry no parameters.
|
|
524
|
+
unpaired: list[str] = field(default_factory=list)
|
|
525
|
+
# The colours the file binds to bodies and faces.
|
|
526
|
+
paints: list[Paint] = field(default_factory=list)
|