Skip to content

feat(schedules): element and room schedules as CSV from the CLI, the viewer and Python - #289

Merged
DrunkOnJava merged 1 commit into
mainfrom
feat/csv-schedules
Sep 22, 2026
Merged

DrunkOnJava merged 1 commit into
mainfrom
feat/csv-schedules

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

Element and room schedules as CSV — the spreadsheet people actually want from a Revit file they cannot open — from a new rvt-schedule CLI, the viewer's Schedule panel, and Python's RevitFile.schedule_csv(), all backed by one rvt::ifc::schedule_csv module.

Motivation

The decoded model (walls, doors with their host wall, windows, columns, slabs, rooms with names and numbers on Revit 2024 projects) was only reachable as IFC, glTF, SVG or raw JSON. A schedule in Excel / Sheets / LibreOffice is the most common ask from people without Revit.

Changes

  • src/ifc/schedule_csv.rs (new): elements_csv (Revit ElementId, IFC type, predefined type, name, level + elevation, material, x/y/z, rotation, width/depth/height of the emitted rectangular body, host ElementId for doors/windows, body_source, profile_resolved) and rooms_csv (ElementId, number, name, level + elevation, body source). Feet or metres; optional UTF-8 BOM for Excel on Windows; RFC 4180 with CRLF; storey order then numeric ElementId.
    • Only decoded values are written; unknowns are empty cells.
    • No room area: room bodies are record bounding boxes (ProfileResolved = false), and a box area is not a room area.
    • CSV-injection guard: cells come from an untrusted file, so a text cell starting with =, +, -, @, tab or CR is prefixed with ' (OWASP). The older scene_graph::Schedule::to_csv gets the same guard.
  • src/bin/rvt_schedule.rs (new, 19th CLI): rvt-schedule model.rvt → model.elements.csv; --schedule rooms; --metric; --excel; -o - for stdout; refuses to overwrite the input; tells you to run rvt-inspect when nothing decoded.
  • Wasm scheduleCsv(model, kind, metric, excel); viewer Download element schedule (CSV) / Download room schedule (CSV) under Schedule, enabled only when the model has elements / rooms, built on the main-thread wasm instance from fix(viewer): make Export IFC and Export plan SVG work in the browser #288.
  • Python RevitFile.schedule_csv(kind="elements", metric=False, excel=False) + stubs.
  • Docs: README (CLI list "Nineteen", examples, What-works row), user guide "Get A Schedule Into Excel", python.md, viewer-api.md, status.md, support-matrix csv-schedules row (partial: coverage is exactly the decode coverage), CHANGELOG.

Testing

  • tools/check-local.sh with both corpora: fmt, clippy -D warnings, rustdoc -D warnings, 1,276 tests passed, 0 failed
  • cargo +1.85.0 check --profile ci --all-targets (MSRV)
  • Unit tests (7): decoded values vs blanks, host ElementId, storey + natural ElementId order, metric conversion + column names, formula neutralisation and RFC 4180 quoting of an untrusted room name (=HYPERLINK("x"), Lobby, East), BOM toggle, compact numbers
  • tests/rvt_schedule_cli.rs: tier-1 shape (17 columns, no ragged rows, stdout + BOM + metric header), one named error for a missing input, and on 2024_Core_Interior.rvt (corpus-gated) 970 element rows — 360 IFCWALL, 132 IFCDOOR (all hosted), 6 IFCWINDOW, 256 IFCCOLUMN, 116 IFCSPACE — plus 116 room rows with number and name
  • Python: 64 passed (2 new: header shapes, unknown kind raises ValueError)
  • Viewer: wasm-pack build, typecheck, build, network-import audit PASS, Playwright 14 passed — the Einhoven test downloads the element schedule and checks the BOM + header
  • binary_inventory (README "Nineteen CLIs ship"), cli_ergonomics (help examples now include rvt-schedule)

Audit-honesty checklist

  • README / docs reflect the current state after this PR — the support-matrix row is partial and says rows equal decode coverage
  • If a limitation was resolved, the "Known limitations" / "What works today" section in the relevant docs is updated
  • New limitation documented: no room area (bounding-box bodies); schedules are only as complete as the file's decode (typed rows on Revit 2024 projects with element records)
  • Commit messages describe WHAT changed and WHY
  • No emojis in code, docs, or commit messages
  • No private paths, personal email addresses, or internal jargon in committed files
  • N/A: not a reverse-engineering finding

Legal and contribution hygiene

  • I agree this work is licensable under Apache-2.0 (see CONTRIBUTING.md)
  • This PR contains no Autodesk proprietary source, decompiled internals, or NDA'd SDK content (see CLEANROOM.md)
  • Test fixtures: tier-1 synthetics; the magnetar project (MIT) is corpus-gated, not committed

Breaking changes

None. scene_graph::Schedule::to_csv now prefixes formula-like cells with '.

Screenshots or output samples

$ rvt-schedule 2024_Core_Interior.rvt
rvt-schedule: wrote 970 element rows to 2024_Core_Interior.elements.csv
$ head -3 2024_Core_Interior.elements.csv
revit_element_id,ifc_type,predefined_type,name,level,level_elevation_ft,material,x_ft,y_ft,z_ft,rotation_deg,width_ft,depth_ft,height_ft,host_revit_element_id,body_source,profile_resolved
21975,IFCSLAB,FLOOR,BuildingPad-21975,Basement 2,-40,,93.5,69.5,-43,,,,1.5,,partition_element_record_bbox,true
22771,IFCWALL,NOTDEFINED,Wall-22771,Basement 2,-40,,92.75,113.25,-40,,145.5,1.5,40,,partition_element_record_join_trimmed,false
$ rvt-schedule 2024_Core_Interior.rvt --schedule rooms --metric
rvt-schedule: wrote 116 room rows to 2024_Core_Interior.rooms.csv

Related issues

Refs #90 (room boundary polygons — why the room schedule has no area).


Note

Low Risk
Mostly additive export surfaces and defensive CSV escaping; the only behavior change is formula-neutralization in existing Schedule::to_csv output.

Overview
Adds spreadsheet schedules for decoded building elements and rooms, shared across a new rvt-schedule CLI, the browser viewer, and RevitFile.schedule_csv(), all built on rvt::ifc::schedule_csv.

The element CSV includes Revit ElementId, IFC type, level, material, placement, rectangular body dimensions, door/window host ids, and geometry provenance; the room CSV has number, name, and level (no area). Options cover feet vs metres, optional UTF-8 BOM for Excel, and stdout output. Rows reflect decode coverage only (empty cells for unknowns).

Security: text cells that could trigger spreadsheet formula injection are prefixed with ', including in the older scene_graph::Schedule::to_csv.

Docs, support matrix, and tests cover CLI shape, Python API, wasm scheduleCsv, and Playwright download checks.

Reviewed by Cursor Bugbot for commit 8bb1b56. Configure here.

…viewer and Python

rvt::ifc::schedule_csv writes one row per decoded building element
(Revit ElementId, IFC type, level and elevation, material, placement,
rectangular body size, the host wall of each door and window, body
provenance) or per room (number, name, level). Feet or metres, optional
UTF-8 BOM for Excel on Windows, RFC 4180 with CRLF, storey order then
numeric ElementId. Unknowns are empty cells; rooms carry no area because
their bodies are record bounding boxes. Cells come from an untrusted file,
so formula-like text cells are prefixed with ' (OWASP CSV injection), and
the older scene_graph::Schedule::to_csv gets the same guard.

rvt-schedule (19th CLI) writes <input>.elements.csv / .rooms.csv, or
stdout with -o -. The viewer gains Download element / room schedule (CSV)
buttons through a scheduleCsv wasm binding on the main-thread instance;
Python gains RevitFile.schedule_csv(). On 2024_Core_Interior.rvt: 970
element rows (360 walls, 132 hosted doors, 6 windows, 256 columns, 116
rooms) and 116 room rows, pinned by tests/rvt_schedule_cli.rs.
@cursor

cursor Bot commented Sep 22, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_5762536e-2ddf-43b7-8b46-cd820a3bbfe8)

@DrunkOnJava
DrunkOnJava merged commit 65830fc into main Sep 22, 2026
30 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/csv-schedules branch September 22, 2026 19:58
DrunkOnJava added a commit that referenced this pull request Sep 22, 2026
…ield is set (#290)

## Summary

`Global/ElemTable` layout detection no longer mis-measures the record
size when a record's sentinel field is set, which on Autodesk's Snowdon
Towers 2024 architectural sample left every ElementId reading 0 and
disabled element recovery for the whole file. RE-30 records what the
same two Snowdon files show beyond that: element recovery does not yet
generalise past the recorded edge, and the support matrix now says so.

## Motivation

`detect_layout` took the record size from the spacing between the first
two `0xFF` runs. On the Snowdon architectural sample, records 1 and 2
hold `0x10` there, so the first two runs are 120 bytes apart, not 40.
The flush check failed, and all 15,744 rows parsed at 120 bytes read
ElementId 0. Element records join on the declared id set, so none could
match, and the IFC export fell back to 64 plan-loop floor guesses (the
heuristic's cap) with no ElementId and no geometry.

## Changes

- `src/elem_table.rs`: when the measured spacing does not tile the
stream flush against `record_count`, try the known 40- and 28-byte
strides that divide it and do tile it. `record_origin` folds into
`flush_origin`, its only remaining caller. There is a new unit test for
the sparse-sentinel shape.
- The run the detector anchors on is not a marker. It is an optional
`u64` ElementId at record `+4`, and `FF`×8 is its unset value. Set
values are declared ElementIds in 22,368 of 22,368 rows on Core Interior
and 29,131 of 29,177 on Snowdon. This is documented in the module docs
and in `docs/elem-table-record-layout-2026-04-21.md`.
- `reports/element-framing/RE-30-snowdon-generalisation.md` (new): on
both Snowdon files most element frames in every recovered category use a
second prologue whose own ElementId is not at `+0x00`, not in the last
reference slot, and not at any fixed offset before the record. Recovery
stays fail-closed.
- `docs/support-matrix.json`: `element-record-instance-recovery` stays
`verified` on the recorded edge. Its `user_impact` no longer reads as if
any Revit 2024 project would match.
- `.gitignore`: `!corpus/**` no longer re-includes `.DS_Store`.

## Testing

- [x] `tools/check-local.sh` with both corpora before the rebase: fmt,
clippy -D warnings, rustdoc -D warnings, 1,337 tests passed, 0 failed
- [x] After rebasing onto #289: `cargo +1.85.0 check --profile ci
--all-targets` (MSRV) and the ElemTable unit tests (22) pass
- [x] Corpus-gated `elem_table_corpus`, `project_count_fixtures`,
`samples`: unchanged. Core Interior 26,425 records at stride 40,
Einhoven 2,614 at 28, families unchanged.
- [x] Local-only measurement on the Snowdon samples (not committed, not
redistributable):

| file | before | after |
|---|---|---|
| architectural, ElemTable | stride 120, 15,744 rows, distinct ids `{0}`
| stride 40, 47,233 rows, 47,232 distinct ids |
| architectural, `rvt-ifc` | 64 `IfcSlab` `Floor-unnamed` (no id, no
body), 37 `IfcSpace` | 5 `IfcWall` + 1 `IfcSlab` with ElementIds and
bodies, 37 `IfcSpace` |
| structural | stride 40, unchanged | unchanged (8 walls, 3 slabs, 15
spaces) |

## Audit-honesty checklist

- [x] README / docs reflect the current state after this PR. The
support-matrix user impact now states that recovery does not generalise
to the Snowdon samples.
- [x] If a limitation was resolved, the "Known limitations" / "What
works today" section in the relevant docs is updated
- [x] New limitation documented: RE-30 (A-prologue ElementId not
located; structural categories unmapped)
- [x] Commit messages describe WHAT changed and WHY
- [x] No emojis in code, docs, or commit messages
- [x] No private paths, personal email addresses, or internal jargon in
committed files
- [x] Reverse-engineering finding: RE-30 report with hashes, counts and
the three ruled-out hypotheses

## Legal and contribution hygiene

- [x] I agree this work is licensable under Apache-2.0 (see
`CONTRIBUTING.md`)
- [x] This PR contains no Autodesk proprietary source, decompiled
internals, or NDA'd SDK content (see `CLEANROOM.md`)
- [x] Test fixtures: a synthetic 40-byte table in the unit test. The
Snowdon samples are Autodesk's and stay local only.

## Breaking changes

None.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes core ElemTable stride detection used for every project's
declared ElementId set and element-record joins; behavior is gated by
flush checks and unit tests, but wrong stride would silently break
recovery on new file shapes.
> 
> **Overview**
> Fixes **`Global/ElemTable` layout detection** when early records set
the optional ElementId reference at `+4` instead of the unset `FF`×8
pattern. **`detect_layout`** no longer treats the gap between the first
two `0xFF` runs as stride when that spacing does not tile the stream
flush against **`record_count`**; it falls back to known **40-** and
**28-byte** project strides that divide the spacing and do tile.
**`record_origin`** is renamed to **`flush_origin`** and returns
**`Option`** so failed flush checks can trigger the fallback.
> 
> On Autodesk's Snowdon Towers 2024 architectural sample this stops a
**120-byte** misread (15,744 rows with ElementId 0), restores **47,233**
declared ids, and lets partition element records join so IFC export
emits **real walls and slabs** instead of **64** capped plan-loop floor
guesses. Other corpus files are unchanged.
> 
> Docs and honesty: **CHANGELOG**, **elem-table layout** notes (sentinel
semantics), new **RE-30** report (Snowdon still mostly uses an alternate
record prologue without a located ElementId), and **support-matrix**
user impact scoped to the recorded Core Interior edge. **`.gitignore`**
excludes **`corpus/**/.DS_Store`** re-included by `!corpus/**`.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
4028efa49fb72f6da7c018cd3b79a29ee518ba3c. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@DrunkOnJava DrunkOnJava mentioned this pull request Sep 22, 2026
2 of 3 tasks
DrunkOnJava added a commit that referenced this pull request Sep 22, 2026
## Summary

Prepare the v0.2.0 release: the inspection-focused alpha described in
`docs/release-0.2.0-plan.md`. It ships PyPI wheels, prebuilt CLI
archives for 5 platforms and the multi-arch container image. **crates.io
is not part of this release:** no `CARGO_REGISTRY_TOKEN` is configured,
and publishing is deferred. Merging this PR is **not** the release.
Nothing is published until the draft v0.2.0 GitHub Release (archives
attached from a tagged-name `workflow_dispatch` run) is published, which
creates the tag and runs `publish.yml`. Until then the docs on `main`
say 0.2.0 is prepared and not yet published.

## Changes

- Versions: `rvt` and `rvt-py` go to 0.2.0, along with the
`stream_evidence` pin, both lockfiles and
`.release-please-manifest.json`.
- `CHANGELOG.md`: `[Unreleased]` is promoted to `[0.2.0] — 2026-09-22`,
with an empty `[Unreleased]` stub.
- `publish.yml`: when `CARGO_REGISTRY_TOKEN` is not configured, the
crates.io job now logs a warning and exits successfully, so PyPI and the
release binaries still ship. A crate the registry rejects still fails
the job and blocks PyPI, which keeps the protection against publishing
mismatched Rust and Python versions.
- `docs/install.md`: the publication table keeps PyPI at 0.1.2 and marks
the 0.2.0 archives and the container image **not yet published**.
crates.io and docs.rs stay marked **not published**.
- `release-binaries.yml`: a `workflow_dispatch` `tag` input names
archives for a release without uploading, which is used to stage the
draft.
- `docs/release-0.2.0-plan.md` and the CHANGELOG heading: prepared, not
yet released.

## Testing

- [x] `cargo publish --dry-run -p rvt`: packages and verifies 482 files
(1.7 MiB)
- [x] Full local gate on the constituent PRs (#289–#297); this PR only
bumps versions and changes docs and workflow configuration
- [ ] CI on this PR

## Follow-up

crates.io and docs.rs: add a crates.io API token as the repo secret
`CARGO_REGISTRY_TOKEN`, then publish `rvt` 0.2.0 (or 0.2.1), and update
`docs/install.md`.

## Breaking changes

`ElemRecord` gained `owner_id` (#294); a struct literal of it now needs
that field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant