verify-print 0.5.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.
- verify_print-0.5.0/LICENSE +21 -0
- verify_print-0.5.0/PKG-INFO +172 -0
- verify_print-0.5.0/README.md +138 -0
- verify_print-0.5.0/pyproject.toml +43 -0
- verify_print-0.5.0/setup.cfg +4 -0
- verify_print-0.5.0/tests/test_cli.py +130 -0
- verify_print-0.5.0/tests/test_feature_color.py +75 -0
- verify_print-0.5.0/tests/test_mesh_info_and_compare.py +145 -0
- verify_print-0.5.0/tests/test_mesh_integrity.py +80 -0
- verify_print-0.5.0/tests/test_mesh_repair.py +57 -0
- verify_print-0.5.0/tests/test_param_linter.py +88 -0
- verify_print-0.5.0/tests/test_param_linter_xfail_limits.py +107 -0
- verify_print-0.5.0/tests/test_project_check.py +77 -0
- verify_print-0.5.0/tests/test_safezip.py +55 -0
- verify_print-0.5.0/tests/test_slicer_simulate.py +157 -0
- verify_print-0.5.0/tests/test_wall_thickness_and_orientation.py +143 -0
- verify_print-0.5.0/verify_print/__init__.py +47 -0
- verify_print-0.5.0/verify_print/_safezip.py +44 -0
- verify_print-0.5.0/verify_print/cli.py +547 -0
- verify_print-0.5.0/verify_print/feature_color.py +157 -0
- verify_print-0.5.0/verify_print/iteration_compare.py +152 -0
- verify_print-0.5.0/verify_print/mesh_info.py +116 -0
- verify_print-0.5.0/verify_print/mesh_integrity.py +414 -0
- verify_print-0.5.0/verify_print/mesh_repair.py +247 -0
- verify_print-0.5.0/verify_print/param_linter.py +247 -0
- verify_print-0.5.0/verify_print/project_check.py +341 -0
- verify_print-0.5.0/verify_print/slicer_simulate.py +539 -0
- verify_print-0.5.0/verify_print.egg-info/PKG-INFO +172 -0
- verify_print-0.5.0/verify_print.egg-info/SOURCES.txt +31 -0
- verify_print-0.5.0/verify_print.egg-info/dependency_links.txt +1 -0
- verify_print-0.5.0/verify_print.egg-info/entry_points.txt +2 -0
- verify_print-0.5.0/verify_print.egg-info/requires.txt +23 -0
- verify_print-0.5.0/verify_print.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pedro Vega
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: verify-print
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Catch CAD, mesh and slicer-profile bugs before you waste filament
|
|
5
|
+
Author: Pedro Vega
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/pjvega31/verify-print
|
|
8
|
+
Project-URL: Issues, https://github.com/pjvega31/verify-print/issues
|
|
9
|
+
Keywords: 3d-printing,stl,3mf,bambu-studio,orcaslicer,cadquery,trimesh
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering
|
|
12
|
+
Requires-Python: >=3.9
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: trimesh>=4.0
|
|
16
|
+
Requires-Dist: numpy>=1.24
|
|
17
|
+
Requires-Dist: networkx>=3.0
|
|
18
|
+
Requires-Dist: scipy>=1.10
|
|
19
|
+
Requires-Dist: rtree>=1.0
|
|
20
|
+
Provides-Extra: mesh-repair
|
|
21
|
+
Requires-Dist: pymeshlab>=2023.12; extra == "mesh-repair"
|
|
22
|
+
Provides-Extra: cad
|
|
23
|
+
Requires-Dist: cadquery>=2.4; extra == "cad"
|
|
24
|
+
Provides-Extra: slicer
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
27
|
+
Requires-Dist: manifold3d>=2.3; extra == "dev"
|
|
28
|
+
Provides-Extra: all
|
|
29
|
+
Requires-Dist: pymeshlab>=2023.12; extra == "all"
|
|
30
|
+
Requires-Dist: cadquery>=2.4; extra == "all"
|
|
31
|
+
Requires-Dist: pytest>=7.0; extra == "all"
|
|
32
|
+
Requires-Dist: manifold3d>=2.3; extra == "all"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
# verify-print
|
|
36
|
+
|
|
37
|
+
**Catch CAD, mesh and slicer-profile bugs before you waste filament.**
|
|
38
|
+
|
|
39
|
+
`verify-print` is a command-line tool and Python library that checks an FDM print job *before* it reaches the printer: the STL mesh, the CadQuery parameters behind it, the slicer profile, and downloaded 3MF projects. Every check is deterministic, runs in seconds, and returns a CI-friendly exit code.
|
|
40
|
+
|
|
41
|
+

|
|
42
|
+
|
|
43
|
+
<sub>Real output, not a mock-up: `python scripts/make_demo.py` rebuilds both parts and redraws this image.</sub>
|
|
44
|
+
|
|
45
|
+
Built and used in production at **Volta Tech PR**, a 3D-printing shop in Puerto Rico running a small print farm (Bambu Lab P1S, Prusa XL, Anycubic Kobra).
|
|
46
|
+
|
|
47
|
+
> *Español:* hecho y usado en producción en **Volta Tech PR**, Puerto Rico. `verify-print` revisa el modelo, los parámetros CAD y el perfil del slicer **antes** de imprimir, para no perder horas de impresión ni filamento. Las instrucciones de abajo están en inglés; los issues en español son bienvenidos.
|
|
48
|
+
|
|
49
|
+
## Why it exists
|
|
50
|
+
|
|
51
|
+
It came out of a real enclosure project at Volta Tech PR that went through four design iterations (v2.0 → v2.4). Each failed print cost 20–44 hours of printer time. Looking back, every one of those bugs was detectable on the computer first:
|
|
52
|
+
|
|
53
|
+
| Real bug | Check that catches it |
|
|
54
|
+
|---|---|
|
|
55
|
+
| Cable opening modelled on the front face instead of the back | `orientation` |
|
|
56
|
+
| Magnet pockets left a 0.2 mm floor that cracked | `thickness` (partial — see [design note](https://github.com/pjvega31/verify-print/blob/main/docs/thin-pocket-detection.md)) |
|
|
57
|
+
| A hollow filament profile fell back to 2 mm³/s volumetric speed: **44 h instead of 22 h** | `slice --min-speed`, `project` |
|
|
58
|
+
| 18 magnet parameters still defined after the magnet code was commented out | `params` |
|
|
59
|
+
| Alignment posts and magnet pockets indistinguishable in the slicer preview | `feature_color` (library) |
|
|
60
|
+
| 4 alignment posts not fused to the body: 5 disconnected shells | `mesh` |
|
|
61
|
+
|
|
62
|
+
## Install
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install verify-print # mesh, params, info, thickness, orientation, slice, project, compare
|
|
66
|
+
pip install "verify-print[mesh-repair]" # + PyMeshLab deep checks and repair
|
|
67
|
+
pip install "verify-print[cad]" # + CadQuery feature-color export
|
|
68
|
+
pip install "verify-print[all]" # everything, including pytest
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
To work on the code instead, clone the repo and run `pip install -e ".[dev]"`.
|
|
72
|
+
|
|
73
|
+
Python ≥ 3.9. Slicing uses **Bambu Studio 2.8** (default) or **OrcaSlicer 2.3** (`--slicer orca`) installed at the standard macOS path (`/Applications/…`). Slicing on Linux/Windows is not wired up yet — the mesh, params, info and 3MF-settings checks work everywhere.
|
|
74
|
+
|
|
75
|
+
## Quick start
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Is the mesh printable? (watertight, manifold, shells, bbox, mass)
|
|
79
|
+
verify-print mesh part.stl
|
|
80
|
+
|
|
81
|
+
# Bbox, volume, build-volume fit and mass — no slicer needed
|
|
82
|
+
verify-print info part.stl --build-volume 256,256,256 --density 1.27
|
|
83
|
+
|
|
84
|
+
# Thin walls (inward ray casting)
|
|
85
|
+
verify-print thickness part.stl --threshold 0.8 --samples 1000
|
|
86
|
+
|
|
87
|
+
# Does the largest opening face the back (-Y)?
|
|
88
|
+
verify-print orientation part.stl --normal 0,-1,0 --feature cable_opening
|
|
89
|
+
|
|
90
|
+
# Parameters defined but never used (orphans) or used but never defined (ghosts)
|
|
91
|
+
verify-print params params.py body.py lid.py
|
|
92
|
+
|
|
93
|
+
# Real slice with gates: fail if volumetric speed < 5 mm³/s or the print exceeds 24 h
|
|
94
|
+
python3 profiles/bambu/flatten.py --all # once: builds flat/ from your Bambu Studio install
|
|
95
|
+
B="$HOME/Library/Application Support/BambuStudio/system/BBL"
|
|
96
|
+
verify-print slice part.stl \
|
|
97
|
+
--filament profiles/bambu/flat/Volta-PETG-Black.json \
|
|
98
|
+
--process profiles/bambu/flat/Volta-Tech-PETG-P1S-Standard.json \
|
|
99
|
+
--machine "$B/machine/Bambu Lab P1S 0.4 nozzle.json" \
|
|
100
|
+
--min-speed 5.0 --max-hours 24
|
|
101
|
+
|
|
102
|
+
# Before printing a downloaded 3MF: which setting turns a 4 h part into 17 h?
|
|
103
|
+
verify-print project model.3mf --printer "Bambu Lab P1S 0.4 nozzle" --slice --max-hours 6
|
|
104
|
+
|
|
105
|
+
# Everything in a folder (params.py + *.py + *.stl auto-detected)
|
|
106
|
+
verify-print all my_part/
|
|
107
|
+
|
|
108
|
+
# Was the last change better or worse?
|
|
109
|
+
verify-print all my_part/ --json > before.json
|
|
110
|
+
verify-print all my_part/ --json > after.json
|
|
111
|
+
verify-print compare before.json after.json
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Exit codes: `0` pass · `1` fail · `2` usage error. Every subcommand accepts `--json`, and every report carries a `passed` boolean.
|
|
115
|
+
|
|
116
|
+
## What each check does
|
|
117
|
+
|
|
118
|
+
**Mesh (trimesh).** Watertight, manifold, valid volume, disconnected shells, bounding box, mass and centre of mass. `thickness` samples wall thickness by inward ray casting (use the P5 percentile on noisy meshes). `orientation` finds the largest planar opening and compares its normal with the one you expect.
|
|
119
|
+
|
|
120
|
+
**Mesh repair (PyMeshLab, optional).** Self-intersections, non-manifold edges and vertices, duplicate faces, open holes; `--repair` writes a repaired STL and re-validates it.
|
|
121
|
+
|
|
122
|
+
**Slicer simulation.** Runs the Bambu Studio or OrcaSlicer CLI and reads the real numbers: print time, grams, metres, layers, and the *effective* `filament_max_volumetric_speed` after profile inheritance. Optional gates: `--max-hours`, `--max-grams`, `--min-speed`. Accepts several STLs or a folder.
|
|
123
|
+
|
|
124
|
+
**3MF project gate.** Reads `project_settings.config` and `model_settings.config` and applies 9 rules: volumetric speed < 5 mm³/s (fail), layer height < 0.16 mm, infill > 30 % or walls > 4, supports on, accelerations < 2000 mm/s², fuzzy skin on, every key the project changed versus the stock profile, unexpected printer preset, and (with `--slice`) plate time over `--max-hours` with the top-3 features eating the time.
|
|
125
|
+
|
|
126
|
+
**Parameter linter (AST).** Finds keys defined in a params dict but never read (orphans) and keys read but never defined (ghosts — a runtime crash waiting to happen). Dynamic access (`**DICT`, f-string keys) switches that dict to review mode instead of guessing.
|
|
127
|
+
|
|
128
|
+
**Feature colour (CadQuery, optional).** Exports each feature class as a separately coloured object (STLs + `colors.json`, or one GLTF/STEP), so posts and pockets look different in the slicer.
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from verify_print import check_mesh, lint_params, slice_stl
|
|
132
|
+
from verify_print.feature_color import export_features # needs [cad]
|
|
133
|
+
|
|
134
|
+
export_features(
|
|
135
|
+
{"body": (body, "#00BCD4"), "posts": (posts, "#FFD600"), "pockets": (pockets, "#E53935")},
|
|
136
|
+
output_dir="out/", format="stls",
|
|
137
|
+
)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Bundled slicer profiles
|
|
141
|
+
|
|
142
|
+
`profiles/bambu/src/` holds PETG overrides for a Bambu Lab P1S with a 0.4 mm nozzle. The Bambu Studio CLI does not resolve `inherits` in user JSON, so `flatten.py` merges them onto your locally installed Bambu system profiles into `flat/` — generated on your machine, not shipped, because those base profiles are Bambu's (AGPL-3.0). See [profiles/bambu/README.md](https://github.com/pjvega31/verify-print/blob/main/profiles/bambu/README.md) for the measured time differences and the CLI gotchas.
|
|
143
|
+
|
|
144
|
+
## Known limitations
|
|
145
|
+
|
|
146
|
+
- Wall thickness is statistical sampling; a very small thin spot can be missed. Raise `--samples` for tight tolerances.
|
|
147
|
+
- `orientation` needs an open boundary; a fully watertight mesh reports "no hole found".
|
|
148
|
+
- Filament weight is 0 g when the profile has no density, which makes `--max-grams` inert.
|
|
149
|
+
- The project gate reads all plates; plain `slice` reads `plate_1` only.
|
|
150
|
+
- Slicer time estimates are typically ±15–30 % off real prints; no printer calibration is applied.
|
|
151
|
+
- Slicer binaries are looked up at macOS paths only.
|
|
152
|
+
- The parameter linter does not resolve dict aliasing (`p = CASE; p["x"]`); this is an `xfail` test on purpose.
|
|
153
|
+
- `feature_color` works at CAD-authoring time only; it cannot re-colour an existing STL.
|
|
154
|
+
|
|
155
|
+
## Tests
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
pip install -e ".[dev]"
|
|
159
|
+
python -m pytest
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
The test suite needs no slicer installed (slicer output parsing and command building are unit-tested); PyMeshLab and CadQuery tests skip when those extras are missing. `scripts/replay_backtest.py` replays the tool over the git history of a CAD repo to see which commits it would have flagged.
|
|
163
|
+
|
|
164
|
+
## Contributing
|
|
165
|
+
|
|
166
|
+
Bug reports with the failing STL or 3MF attached are the most useful thing you can send — see [CONTRIBUTING.md](https://github.com/pjvega31/verify-print/blob/main/CONTRIBUTING.md).
|
|
167
|
+
|
|
168
|
+
## License
|
|
169
|
+
|
|
170
|
+
MIT — see [LICENSE](https://github.com/pjvega31/verify-print/blob/main/LICENSE). Optional extras keep their own licenses: PyMeshLab is GPL-3.0, CadQuery is Apache-2.0. Bambu Studio and OrcaSlicer (AGPL-3.0) are called as external programs, never bundled.
|
|
171
|
+
|
|
172
|
+
Maintained as time allows; issues and PRs are reviewed but response times vary.
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# verify-print
|
|
2
|
+
|
|
3
|
+
**Catch CAD, mesh and slicer-profile bugs before you waste filament.**
|
|
4
|
+
|
|
5
|
+
`verify-print` is a command-line tool and Python library that checks an FDM print job *before* it reaches the printer: the STL mesh, the CadQuery parameters behind it, the slicer profile, and downloaded 3MF projects. Every check is deterministic, runs in seconds, and returns a CI-friendly exit code.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
<sub>Real output, not a mock-up: `python scripts/make_demo.py` rebuilds both parts and redraws this image.</sub>
|
|
10
|
+
|
|
11
|
+
Built and used in production at **Volta Tech PR**, a 3D-printing shop in Puerto Rico running a small print farm (Bambu Lab P1S, Prusa XL, Anycubic Kobra).
|
|
12
|
+
|
|
13
|
+
> *Español:* hecho y usado en producción en **Volta Tech PR**, Puerto Rico. `verify-print` revisa el modelo, los parámetros CAD y el perfil del slicer **antes** de imprimir, para no perder horas de impresión ni filamento. Las instrucciones de abajo están en inglés; los issues en español son bienvenidos.
|
|
14
|
+
|
|
15
|
+
## Why it exists
|
|
16
|
+
|
|
17
|
+
It came out of a real enclosure project at Volta Tech PR that went through four design iterations (v2.0 → v2.4). Each failed print cost 20–44 hours of printer time. Looking back, every one of those bugs was detectable on the computer first:
|
|
18
|
+
|
|
19
|
+
| Real bug | Check that catches it |
|
|
20
|
+
|---|---|
|
|
21
|
+
| Cable opening modelled on the front face instead of the back | `orientation` |
|
|
22
|
+
| Magnet pockets left a 0.2 mm floor that cracked | `thickness` (partial — see [design note](https://github.com/pjvega31/verify-print/blob/main/docs/thin-pocket-detection.md)) |
|
|
23
|
+
| A hollow filament profile fell back to 2 mm³/s volumetric speed: **44 h instead of 22 h** | `slice --min-speed`, `project` |
|
|
24
|
+
| 18 magnet parameters still defined after the magnet code was commented out | `params` |
|
|
25
|
+
| Alignment posts and magnet pockets indistinguishable in the slicer preview | `feature_color` (library) |
|
|
26
|
+
| 4 alignment posts not fused to the body: 5 disconnected shells | `mesh` |
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install verify-print # mesh, params, info, thickness, orientation, slice, project, compare
|
|
32
|
+
pip install "verify-print[mesh-repair]" # + PyMeshLab deep checks and repair
|
|
33
|
+
pip install "verify-print[cad]" # + CadQuery feature-color export
|
|
34
|
+
pip install "verify-print[all]" # everything, including pytest
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
To work on the code instead, clone the repo and run `pip install -e ".[dev]"`.
|
|
38
|
+
|
|
39
|
+
Python ≥ 3.9. Slicing uses **Bambu Studio 2.8** (default) or **OrcaSlicer 2.3** (`--slicer orca`) installed at the standard macOS path (`/Applications/…`). Slicing on Linux/Windows is not wired up yet — the mesh, params, info and 3MF-settings checks work everywhere.
|
|
40
|
+
|
|
41
|
+
## Quick start
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Is the mesh printable? (watertight, manifold, shells, bbox, mass)
|
|
45
|
+
verify-print mesh part.stl
|
|
46
|
+
|
|
47
|
+
# Bbox, volume, build-volume fit and mass — no slicer needed
|
|
48
|
+
verify-print info part.stl --build-volume 256,256,256 --density 1.27
|
|
49
|
+
|
|
50
|
+
# Thin walls (inward ray casting)
|
|
51
|
+
verify-print thickness part.stl --threshold 0.8 --samples 1000
|
|
52
|
+
|
|
53
|
+
# Does the largest opening face the back (-Y)?
|
|
54
|
+
verify-print orientation part.stl --normal 0,-1,0 --feature cable_opening
|
|
55
|
+
|
|
56
|
+
# Parameters defined but never used (orphans) or used but never defined (ghosts)
|
|
57
|
+
verify-print params params.py body.py lid.py
|
|
58
|
+
|
|
59
|
+
# Real slice with gates: fail if volumetric speed < 5 mm³/s or the print exceeds 24 h
|
|
60
|
+
python3 profiles/bambu/flatten.py --all # once: builds flat/ from your Bambu Studio install
|
|
61
|
+
B="$HOME/Library/Application Support/BambuStudio/system/BBL"
|
|
62
|
+
verify-print slice part.stl \
|
|
63
|
+
--filament profiles/bambu/flat/Volta-PETG-Black.json \
|
|
64
|
+
--process profiles/bambu/flat/Volta-Tech-PETG-P1S-Standard.json \
|
|
65
|
+
--machine "$B/machine/Bambu Lab P1S 0.4 nozzle.json" \
|
|
66
|
+
--min-speed 5.0 --max-hours 24
|
|
67
|
+
|
|
68
|
+
# Before printing a downloaded 3MF: which setting turns a 4 h part into 17 h?
|
|
69
|
+
verify-print project model.3mf --printer "Bambu Lab P1S 0.4 nozzle" --slice --max-hours 6
|
|
70
|
+
|
|
71
|
+
# Everything in a folder (params.py + *.py + *.stl auto-detected)
|
|
72
|
+
verify-print all my_part/
|
|
73
|
+
|
|
74
|
+
# Was the last change better or worse?
|
|
75
|
+
verify-print all my_part/ --json > before.json
|
|
76
|
+
verify-print all my_part/ --json > after.json
|
|
77
|
+
verify-print compare before.json after.json
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Exit codes: `0` pass · `1` fail · `2` usage error. Every subcommand accepts `--json`, and every report carries a `passed` boolean.
|
|
81
|
+
|
|
82
|
+
## What each check does
|
|
83
|
+
|
|
84
|
+
**Mesh (trimesh).** Watertight, manifold, valid volume, disconnected shells, bounding box, mass and centre of mass. `thickness` samples wall thickness by inward ray casting (use the P5 percentile on noisy meshes). `orientation` finds the largest planar opening and compares its normal with the one you expect.
|
|
85
|
+
|
|
86
|
+
**Mesh repair (PyMeshLab, optional).** Self-intersections, non-manifold edges and vertices, duplicate faces, open holes; `--repair` writes a repaired STL and re-validates it.
|
|
87
|
+
|
|
88
|
+
**Slicer simulation.** Runs the Bambu Studio or OrcaSlicer CLI and reads the real numbers: print time, grams, metres, layers, and the *effective* `filament_max_volumetric_speed` after profile inheritance. Optional gates: `--max-hours`, `--max-grams`, `--min-speed`. Accepts several STLs or a folder.
|
|
89
|
+
|
|
90
|
+
**3MF project gate.** Reads `project_settings.config` and `model_settings.config` and applies 9 rules: volumetric speed < 5 mm³/s (fail), layer height < 0.16 mm, infill > 30 % or walls > 4, supports on, accelerations < 2000 mm/s², fuzzy skin on, every key the project changed versus the stock profile, unexpected printer preset, and (with `--slice`) plate time over `--max-hours` with the top-3 features eating the time.
|
|
91
|
+
|
|
92
|
+
**Parameter linter (AST).** Finds keys defined in a params dict but never read (orphans) and keys read but never defined (ghosts — a runtime crash waiting to happen). Dynamic access (`**DICT`, f-string keys) switches that dict to review mode instead of guessing.
|
|
93
|
+
|
|
94
|
+
**Feature colour (CadQuery, optional).** Exports each feature class as a separately coloured object (STLs + `colors.json`, or one GLTF/STEP), so posts and pockets look different in the slicer.
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from verify_print import check_mesh, lint_params, slice_stl
|
|
98
|
+
from verify_print.feature_color import export_features # needs [cad]
|
|
99
|
+
|
|
100
|
+
export_features(
|
|
101
|
+
{"body": (body, "#00BCD4"), "posts": (posts, "#FFD600"), "pockets": (pockets, "#E53935")},
|
|
102
|
+
output_dir="out/", format="stls",
|
|
103
|
+
)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Bundled slicer profiles
|
|
107
|
+
|
|
108
|
+
`profiles/bambu/src/` holds PETG overrides for a Bambu Lab P1S with a 0.4 mm nozzle. The Bambu Studio CLI does not resolve `inherits` in user JSON, so `flatten.py` merges them onto your locally installed Bambu system profiles into `flat/` — generated on your machine, not shipped, because those base profiles are Bambu's (AGPL-3.0). See [profiles/bambu/README.md](https://github.com/pjvega31/verify-print/blob/main/profiles/bambu/README.md) for the measured time differences and the CLI gotchas.
|
|
109
|
+
|
|
110
|
+
## Known limitations
|
|
111
|
+
|
|
112
|
+
- Wall thickness is statistical sampling; a very small thin spot can be missed. Raise `--samples` for tight tolerances.
|
|
113
|
+
- `orientation` needs an open boundary; a fully watertight mesh reports "no hole found".
|
|
114
|
+
- Filament weight is 0 g when the profile has no density, which makes `--max-grams` inert.
|
|
115
|
+
- The project gate reads all plates; plain `slice` reads `plate_1` only.
|
|
116
|
+
- Slicer time estimates are typically ±15–30 % off real prints; no printer calibration is applied.
|
|
117
|
+
- Slicer binaries are looked up at macOS paths only.
|
|
118
|
+
- The parameter linter does not resolve dict aliasing (`p = CASE; p["x"]`); this is an `xfail` test on purpose.
|
|
119
|
+
- `feature_color` works at CAD-authoring time only; it cannot re-colour an existing STL.
|
|
120
|
+
|
|
121
|
+
## Tests
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
pip install -e ".[dev]"
|
|
125
|
+
python -m pytest
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The test suite needs no slicer installed (slicer output parsing and command building are unit-tested); PyMeshLab and CadQuery tests skip when those extras are missing. `scripts/replay_backtest.py` replays the tool over the git history of a CAD repo to see which commits it would have flagged.
|
|
129
|
+
|
|
130
|
+
## Contributing
|
|
131
|
+
|
|
132
|
+
Bug reports with the failing STL or 3MF attached are the most useful thing you can send — see [CONTRIBUTING.md](https://github.com/pjvega31/verify-print/blob/main/CONTRIBUTING.md).
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
MIT — see [LICENSE](https://github.com/pjvega31/verify-print/blob/main/LICENSE). Optional extras keep their own licenses: PyMeshLab is GPL-3.0, CadQuery is Apache-2.0. Bambu Studio and OrcaSlicer (AGPL-3.0) are called as external programs, never bundled.
|
|
137
|
+
|
|
138
|
+
Maintained as time allows; issues and PRs are reviewed but response times vary.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "verify-print"
|
|
7
|
+
version = "0.5.0"
|
|
8
|
+
description = "Catch CAD, mesh and slicer-profile bugs before you waste filament"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
authors = [{name = "Pedro Vega"}]
|
|
12
|
+
license = "MIT"
|
|
13
|
+
license-files = ["LICENSE"]
|
|
14
|
+
keywords = ["3d-printing", "stl", "3mf", "bambu-studio", "orcaslicer", "cadquery", "trimesh"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Topic :: Scientific/Engineering",
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
"trimesh>=4.0",
|
|
21
|
+
"numpy>=1.24",
|
|
22
|
+
# trimesh soft deps that verify-print needs: shells (graph), ray casting (thickness/orientation)
|
|
23
|
+
"networkx>=3.0",
|
|
24
|
+
"scipy>=1.10",
|
|
25
|
+
"rtree>=1.0",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.optional-dependencies]
|
|
29
|
+
mesh-repair = ["pymeshlab>=2023.12"]
|
|
30
|
+
cad = ["cadquery>=2.4"]
|
|
31
|
+
slicer = []
|
|
32
|
+
dev = ["pytest>=7.0", "manifold3d>=2.3"]
|
|
33
|
+
all = ["pymeshlab>=2023.12", "cadquery>=2.4", "pytest>=7.0", "manifold3d>=2.3"]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://github.com/pjvega31/verify-print"
|
|
37
|
+
Issues = "https://github.com/pjvega31/verify-print/issues"
|
|
38
|
+
|
|
39
|
+
[project.scripts]
|
|
40
|
+
verify-print = "verify_print.cli:main"
|
|
41
|
+
|
|
42
|
+
[tool.setuptools.packages.find]
|
|
43
|
+
include = ["verify_print*"]
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"""Tests for CLI — focus on --json output + exit codes.
|
|
2
|
+
|
|
3
|
+
Smoke tests that hit the argparse layer end-to-end. Real slicer subprocess
|
|
4
|
+
is NOT invoked here (too slow); slicer-specific parsing is in test_slicer_simulate.
|
|
5
|
+
"""
|
|
6
|
+
import json
|
|
7
|
+
import sys
|
|
8
|
+
from io import StringIO
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
import pytest
|
|
12
|
+
import trimesh
|
|
13
|
+
|
|
14
|
+
from verify_print.cli import main
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@pytest.fixture
|
|
18
|
+
def watertight_box_stl(tmp_path: Path) -> Path:
|
|
19
|
+
box = trimesh.creation.box(extents=(50, 30, 20))
|
|
20
|
+
p = tmp_path / "good.stl"
|
|
21
|
+
box.export(str(p), file_type="stl")
|
|
22
|
+
return p
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
FIXTURES = Path(__file__).parent / "fixtures"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _run_cli(args: list[str], capsys) -> tuple[int, str]:
|
|
29
|
+
code = main(args)
|
|
30
|
+
captured = capsys.readouterr()
|
|
31
|
+
return code, captured.out
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_mesh_human_pass(watertight_box_stl: Path, capsys):
|
|
35
|
+
code, out = _run_cli(["mesh", str(watertight_box_stl)], capsys)
|
|
36
|
+
assert code == 0
|
|
37
|
+
assert "PASS" in out
|
|
38
|
+
assert "watertight" in out.lower()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_mesh_json_pass(watertight_box_stl: Path, capsys):
|
|
42
|
+
code, out = _run_cli(["mesh", str(watertight_box_stl), "--json"], capsys)
|
|
43
|
+
assert code == 0
|
|
44
|
+
payload = json.loads(out)
|
|
45
|
+
assert payload["passed"] is True
|
|
46
|
+
assert payload["is_watertight"] is True
|
|
47
|
+
assert payload["num_disconnected_shells"] == 1
|
|
48
|
+
assert "bounding_box_mm" in payload
|
|
49
|
+
assert len(payload["bounding_box_mm"]) == 3
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_params_human_fail(capsys):
|
|
53
|
+
code, out = _run_cli(
|
|
54
|
+
[
|
|
55
|
+
"params",
|
|
56
|
+
str(FIXTURES / "params_with_orphans.py"),
|
|
57
|
+
str(FIXTURES / "cad_with_some_usage.py"),
|
|
58
|
+
],
|
|
59
|
+
capsys,
|
|
60
|
+
)
|
|
61
|
+
assert code == 1
|
|
62
|
+
assert "ORPHAN" in out
|
|
63
|
+
assert "top_magnet_count" in out
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def test_params_json_fail(capsys):
|
|
67
|
+
code, out = _run_cli(
|
|
68
|
+
[
|
|
69
|
+
"params",
|
|
70
|
+
str(FIXTURES / "params_with_orphans.py"),
|
|
71
|
+
str(FIXTURES / "cad_with_some_usage.py"),
|
|
72
|
+
"--json",
|
|
73
|
+
],
|
|
74
|
+
capsys,
|
|
75
|
+
)
|
|
76
|
+
assert code == 1
|
|
77
|
+
payload = json.loads(out)
|
|
78
|
+
assert payload["passed"] is False
|
|
79
|
+
assert len(payload["orphans"]) >= 4
|
|
80
|
+
# Sets are serialized as sorted lists
|
|
81
|
+
assert isinstance(payload["defined_keys"]["CASE"], list)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def test_all_human_no_slicer_or_repair(tmp_path: Path, capsys):
|
|
85
|
+
# Build a synthetic project dir
|
|
86
|
+
(tmp_path / "params.py").write_text("CASE = {'x': 1, 'orphan_key': 2}")
|
|
87
|
+
(tmp_path / "build.py").write_text("from params import CASE\nprint(CASE['x'])")
|
|
88
|
+
box = trimesh.creation.box(extents=(20, 20, 20))
|
|
89
|
+
box.export(str(tmp_path / "model.stl"), file_type="stl")
|
|
90
|
+
|
|
91
|
+
code, out = _run_cli(["all", str(tmp_path)], capsys)
|
|
92
|
+
# Should fail due to orphan 'orphan_key'
|
|
93
|
+
assert code == 1
|
|
94
|
+
assert "params" in out.lower()
|
|
95
|
+
assert "mesh" in out.lower()
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def test_all_json_aggregate(tmp_path: Path, capsys):
|
|
99
|
+
(tmp_path / "params.py").write_text("CASE = {'x': 1, 'orphan_key': 2}")
|
|
100
|
+
(tmp_path / "build.py").write_text("from params import CASE\nprint(CASE['x'])")
|
|
101
|
+
box = trimesh.creation.box(extents=(20, 20, 20))
|
|
102
|
+
box.export(str(tmp_path / "model.stl"), file_type="stl")
|
|
103
|
+
|
|
104
|
+
code, out = _run_cli(["all", str(tmp_path), "--json"], capsys)
|
|
105
|
+
payload = json.loads(out)
|
|
106
|
+
assert payload["passed"] is False
|
|
107
|
+
assert payload["failures"] >= 1
|
|
108
|
+
assert payload["stl_files_found"] == 1
|
|
109
|
+
assert payload["code_files_scanned"] == 1
|
|
110
|
+
assert payload["params"]["passed"] is False
|
|
111
|
+
assert payload["include_slice"] is False
|
|
112
|
+
assert payload["include_repair"] is False
|
|
113
|
+
assert len(payload["mesh"]) == 1
|
|
114
|
+
assert payload["mesh"][0]["passed"] is True
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def test_all_includes_repair_when_flag_set(tmp_path: Path, capsys):
|
|
118
|
+
pymeshlab = pytest.importorskip("pymeshlab")
|
|
119
|
+
(tmp_path / "params.py").write_text("CASE = {'x': 1}")
|
|
120
|
+
(tmp_path / "build.py").write_text("from params import CASE\nprint(CASE['x'])")
|
|
121
|
+
box = trimesh.creation.box(extents=(20, 20, 20))
|
|
122
|
+
box.export(str(tmp_path / "model.stl"), file_type="stl")
|
|
123
|
+
|
|
124
|
+
code, out = _run_cli(
|
|
125
|
+
["all", str(tmp_path), "--include-repair", "--json"],
|
|
126
|
+
capsys,
|
|
127
|
+
)
|
|
128
|
+
payload = json.loads(out)
|
|
129
|
+
assert payload["include_repair"] is True
|
|
130
|
+
assert len(payload["repair"]) == 1
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""Tests for feature_color — CADQuery Assembly multi-color export.
|
|
2
|
+
|
|
3
|
+
CADQuery skipif: tests only run if cadquery is installed.
|
|
4
|
+
"""
|
|
5
|
+
import json
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
import pytest
|
|
9
|
+
|
|
10
|
+
cq = pytest.importorskip("cadquery")
|
|
11
|
+
|
|
12
|
+
from verify_print.feature_color import export_features, _hex_to_rgb01
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_hex_to_rgb01_basic():
|
|
16
|
+
r, g, b, a = _hex_to_rgb01("#FF0000")
|
|
17
|
+
assert r == 1.0
|
|
18
|
+
assert g == 0.0
|
|
19
|
+
assert b == 0.0
|
|
20
|
+
assert a == 1.0
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_hex_to_rgb01_cyan():
|
|
24
|
+
r, g, b, _a = _hex_to_rgb01("#00BCD4")
|
|
25
|
+
assert g == pytest.approx(0xBC / 255)
|
|
26
|
+
assert b == pytest.approx(0xD4 / 255)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_hex_to_rgb01_no_hash():
|
|
30
|
+
r, _g, _b, _a = _hex_to_rgb01("FF0000")
|
|
31
|
+
assert r == 1.0
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_hex_to_rgb01_invalid_raises():
|
|
35
|
+
with pytest.raises(ValueError):
|
|
36
|
+
_hex_to_rgb01("#FFF")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@pytest.fixture
|
|
40
|
+
def two_box_features():
|
|
41
|
+
body = cq.Workplane("XY").box(50, 30, 20)
|
|
42
|
+
post = cq.Workplane("XY").circle(2).extrude(10)
|
|
43
|
+
return {
|
|
44
|
+
"main_body": (body, "#00BCD4"),
|
|
45
|
+
"alignment_post": (post, "#FFD600"),
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_export_features_stls_creates_files(tmp_path: Path, two_box_features):
|
|
50
|
+
report = export_features(two_box_features, output_dir=tmp_path, format="stls")
|
|
51
|
+
assert (tmp_path / "feature_main_body.stl").exists()
|
|
52
|
+
assert (tmp_path / "feature_alignment_post.stl").exists()
|
|
53
|
+
assert (tmp_path / "colors.json").exists()
|
|
54
|
+
assert "main_body" in report.features_exported
|
|
55
|
+
assert "alignment_post" in report.features_exported
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def test_export_features_stls_color_manifest(tmp_path: Path, two_box_features):
|
|
59
|
+
export_features(two_box_features, output_dir=tmp_path, format="stls")
|
|
60
|
+
manifest = json.loads((tmp_path / "colors.json").read_text())
|
|
61
|
+
assert manifest["colors"]["main_body"] == "#00BCD4"
|
|
62
|
+
assert manifest["colors"]["alignment_post"] == "#FFD600"
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def test_export_features_gltf_creates_single_file(tmp_path: Path, two_box_features):
|
|
66
|
+
report = export_features(
|
|
67
|
+
two_box_features, output_dir=tmp_path, format="gltf", base_name="enclosure_test"
|
|
68
|
+
)
|
|
69
|
+
assert (tmp_path / "enclosure_test.gltf").exists()
|
|
70
|
+
assert report.format == "gltf"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def test_export_features_invalid_format_raises(tmp_path: Path, two_box_features):
|
|
74
|
+
with pytest.raises(ValueError):
|
|
75
|
+
export_features(two_box_features, output_dir=tmp_path, format="obj")
|