Repository navigation
feat(python): draw doors and windows from their saved meshes, as rvt-ifc does - #1146
Conversation
…ifc does Since 0.11.0 rvt-ifc and rvt-gltf draw the doors and windows of Revit 2023 to 2027 files from their saved meshes; Python's write_ifc() and rvt_to_ifc() kept their bounding boxes, so the 0.11.0 wheel's IFC differed from the CLI's for the same file. Griffin decided on 2026-10-30 that Python and the viewer follow the CLI's default. rvt::ifc::saved_meshes::default_scope now holds the default (doors and windows on Revit 2023 to 2027) for every caller; rvt-ifc and rvt-gltf use it unchanged. Python's write_ifc(), rvt_to_ifc(), export_diagnostics(), export_diagnostics_json() and rvt_to_ifc_diagnostics() take saved_meshes=True, attach the meshes and recount the diagnostics as rvt-ifc does; False keeps the boxes, and a RuntimeWarning says when the saved graphics could not be read.
|
Self-review with verification. CLI unchanged. Wheel equals the CLI. I took this PR's Linux wheel (CI run 41070401225, artifact
At 0.11.0 the same wheel check gave the CLI's Code. |
…toggle (#1150) ## Summary The browser viewer draws the doors and windows of Revit 2023 to 2027 files from the meshes Revit saved for them, as `rvt-ifc` and `rvt-gltf` do by default, with a "Draw doors and windows from saved meshes" option in File status that keeps their boxes. Its memory and load time are measured in Playwright on the reference models (below). Stacked on #1146: the first commit is that PR's (`default_scope`, the Python package) and shows here until it lands. This PR's commit is the second. ## Motivation Since 0.11.0 the CLIs draw doors and windows from their saved meshes, so what the viewer showed and exported (glTF and IFC) differed from the command line's for the same file. Griffin decided on 2026-10-30: "Python and viewer follow the CLI default, with an opt-out; the viewer's memory and load time are measured in Playwright on the reference models before it lands." ## Changes - `rvt-wasm/src/lib.rs`: `openRvtBytesWithDiagnosticsMode` and `openRvtBytesWithDiagnosticsModeAndOpenLimits` attach the default saved meshes after the export (`ifc::saved_meshes::default_scope`, `attach_scoped_with_control`, then `recount_exported` and `record_unread_streams`, as `rvt-py` does). The options object gains `savedMeshes?: boolean` (default true; false keeps the boxes and skips the pass). When the saved graphics cannot be read the model keeps its boxes and the diagnostics carry a warning. No binding added, no signature changed (`tools/ci/wasm-api.py compat` and `docs` pass). - `viewer/index.html`, `src/main.ts`, `src/styles.css`: the option in File status, on by default, on the existing checkbox style; changing it reopens the open file with `savedMeshes` and the file's own limits (a large-model retry stays large-model); it is disabled while a file loads. `?savedMeshes=0` starts it off. The Shapes row says how many bodies came from saved meshes. - `viewer/src/worker.ts`: reports what an open cost (the wasm open call, the whole worker, the wasm memory after the parse, the worker heap); `main.ts` keeps it with the load time in `data-load-stats` on `#status`. - `viewer/tests/saved-meshes-measure.spec.ts`, `playwright.config.ts`, `.github/workflows/deploy-viewer.yml`: the measurement (below). It runs alone (`RVT_VIEWER_MEASURE=1`, one worker) after the suite, and the JSON is uploaded as the `viewer-saved-meshes-measurement` artifact. - `docs/viewer-api.md`, `viewer/README.md`, `changelog.d/changed/viewer-saved-meshes.md`. `?savedMeshes=0` differs from `?maxStreamBytes=` on purpose: the limits describe one file and apply to the first open only, but the option is a visible toggle, which would otherwise turn itself back on after one file. It applies to every open until the toggle is changed. ## Testing Unit tests are banned in this repository: none added. No local build or test runs (the repository's rule); GitHub's runners are the gate. - [x] `tools/check-local.sh` passes: not run locally (the repository's rule); `CI passed` is green - [x] Verified end to end on real Revit files: Core Interior, Einhoven (MIT, magnetar-io/revit-test-datasets) and RE1's four models (MIT, Drshelden/IFC-ECS), opened in the viewer by `tests/saved-meshes-measure.spec.ts` (reproduce: `RVT_VIEWER_MEASURE=1 pnpm exec playwright test` in `viewer/`, or run Deploy viewer); the table below is its output - [x] Not an IFC exporter change (the viewer's wasm adds the CLI's existing saved-mesh step); no witness replay - [x] Not a performance change in the library; the cost is measured, not tuned ## Measurement From Deploy viewer run [41072412126](https://github.com/DrunkOnJava/rvt-rs/actions/runs/41072412126) at 60f0c44 (the second commit only drops a column and edits the changelog fragment). Chromium 156 on GitHub's ubuntu-24.04 runner (4 CPUs), one open per setting, each in a fresh browser context, the setting order alternating by model. `tests/saved-meshes-measure.spec.ts` ran alone after the suite; its JSON is the `viewer-saved-meshes-measurement` artifact of that run. | Model | Revit | File MiB | Saved meshes | Load s | Open s | Wasm MiB | Page heap MiB | Doors and windows from meshes | Box bodies | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | 2024_Core_Interior | 2024 | 32 | off | 24.5 | 23.4 | 324 | 20 | 0 of 138 | 138 | | 2024_Core_Interior | 2024 | 32 | on | 25.6 | 24.3 | 324 | 30 | 138 of 138 | 0 | | Revit_IFC5_Einhoven | 2023 | 1 | off | 0.9 | 0.7 | 23 | 7 | 0 of 2 | 11 | | Revit_IFC5_Einhoven | 2023 | 1 | on | 1.0 | 0.7 | 23 | 7 | 2 of 2 | 9 | | RE1-Architecture | 2025 | 6 | off | 6.8 | 6.5 | 100 | 9 | 0 of 5 | 57 | | RE1-Architecture | 2025 | 6 | on | 7.1 | 6.8 | 100 | 9 | 5 of 5 | 52 | | RE1-Mechanical | 2025 | 3 | off | 3.6 | 3.3 | 67 | 7 | 0 of 0 | 68 | | RE1-Mechanical | 2025 | 3 | on | 3.8 | 3.4 | 67 | 7 | 0 of 0 | 68 | | RE1-Plumbing | 2025 | 3 | off | 3.5 | 3.1 | 60 | 11 | 0 of 0 | 61 | | RE1-Plumbing | 2025 | 3 | on | 3.6 | 3.2 | 60 | 9 | 0 of 0 | 61 | | RE1-Electrical | 2025 | 13 | off | 8.1 | 7.8 | 170 | 7 | 0 of 0 | 49 | | RE1-Electrical | 2025 | 13 | on | 8.0 | 7.7 | 170 | 8 | 0 of 0 | 49 | Load is the click to the loaded model as the viewer measures it; open is the wasm open call alone, where the saved graphics are read; wasm is the linear memory after the whole parse (it only grows, so it is the peak against the 4 GiB a tab can hold); page heap is the main thread's JavaScript heap after the load. - Repeated on this PR's head, 2c5d1c5 (run [41075018095](https://github.com/DrunkOnJava/rvt-rs/actions/runs/41075018095)): Core Interior 24.5 s off, 25.4 s on, 324 MiB both; RE1 Architecture 6.7 s and 7.0 s, 100 MiB both; Einhoven 0.9 s and 1.0 s, 23 MiB both; page heap 20 to 34 MiB on Core Interior. All 7 measurement tests and the 31-test suite pass in both runs. - Time: the saved meshes cost 1.1 s of Core Interior's 24.5 s (4%), 0.3 s on RE1 Architecture and 0.1 s on Einhoven. The three RE1 models with no doors or windows have no candidate, so the pass reads nothing; their on-off differences (-0.1 to +0.2 s) are the noise of one run each, which also bounds how far to trust the first three. - Memory: the wasm memory is identical with the option on and off on every model (324 MiB for Core Interior's 32 MiB file, about ten times the file), so the saved-graphics pass stayed inside the peak the export had already reached. The page holds 10 MiB more on Core Interior (20 to 30 MiB), the 138 door and window meshes in the model it keeps. - The spec asserts, on every model, that off draws no saved-mesh bodies, that on draws only doors and windows, keeps the same elements, and removes exactly as many bounding boxes as it draws meshes, and that on Core Interior it draws at least one. A second test checks the toggle: it reopens the open file, off gives 0 meshes and 138 boxes back, on again gives the same 138. - Not measured: a model near the 4 GiB ceiling. The largest model Deploy viewer has is Core Interior; the BIM4LCA office and Snowdon Towers are not fetched there. A file the export barely fits could in principle fail in the saved-graphics pass, which cannot degrade to boxes the way a read error does (a wasm out-of-memory is a trap); the toggle stays available after a failed open, and turning it off reopens the file without the pass. - Pins: none moved. The journey spec's counts against the CLI's pinned manifests (material_count, by_ifc_type, IFCPROPERTYSET, IFCRELFILLSELEMENT, Einhoven's building_elements_with_geometry) pass unchanged with the option on by default. ## Audit-honesty checklist - [x] README / docs reflect the current state after this PR (`docs/viewer-api.md`, `viewer/README.md`); the root README's v0.11.0 list is left alone - [x] Changelog fragment `changelog.d/changed/viewer-saved-meshes.md` - [x] No limitation resolved or introduced beyond the cost measured above - [x] Commit message describes what and why - [x] No emojis, no private paths or personal addresses in committed files - [x] Not a reverse-engineering finding ## Legal and contribution hygiene - [x] Apache-2.0 - [x] No Autodesk proprietary source, decompiled internals or NDA'd SDK content - [x] No new fixtures; the spec reads the models CI already fetches (MIT) ## Breaking changes None. The wasm bindings keep their signatures; `savedMeshes` is an optional field of the options object, and the viewer is the only caller. ## Screenshots or output samples The measurement above. The option sits under the status panel in File status. ## Related issues Refs #1146.
Summary
Python's
write_ifc()andrvt_to_ifc()now draw the doors and windows of Revit 2023 to 2027 files from their saved meshes, asrvt-ifcandrvt-gltfhave since 0.11.0. The diagnostics functions describe that export.saved_meshes=Falsekeeps the boxes, asrvt-ifc --no-saved-meshesdoes.Motivation
Griffin's decision of 2026-10-30 ("Python and viewer"), made after the 0.11.0 release check found the wheel's IFC differed from the CLI's for the same file. The wheel equalled
rvt-ifc --no-saved-mesheson Core Interior, Einhoven and RE1 Architecture. This PR is the Python half. The viewer follows in a separate PR, after its memory and load time are measured in Playwright.Changes
src/ifc/saved_meshes.rs:default_scope(rf)returns the default (doors and windows on Revit 2023 to 2027, none elsewhere) for every caller.src/bin/rvt_ifc.rs,src/bin/rvt_gltf.rs: use it in place of their copies of the same rule. No behaviour change.rvt-py/src/lib.rs:attach_saved_meshesattaches the default scope, recounts the diagnostics and re-records unread streams, asrvt-ifcdoes. It warns (RuntimeWarning) and keeps the boxes when the saved graphics cannot be read.write_ifc,rvt_to_ifc,export_diagnostics,export_diagnostics_jsonandrvt_to_ifc_diagnosticsgainsaved_meshes=True.python/rvt/__init__.pyianddocs/python.md: the new keyword.changelog.d/changed/python-saved-meshes.md.Testing
Unit tests are banned and none are added. The check is end to end:
base=mainandkeep_ifc: the CLI exports must stay byte-identical, since only their scope lookup moved.Both results are added below before this PR is armed.
Audit-honesty checklist
Legal and contribution hygiene
Breaking changes
None to the API: each function gains a keyword with a default. The default output changes. Python users who want the 0.11.0 bodies pass
saved_meshes=False.