Skip to content

research(families): rebuild a family's extrusions from their sketch curves, and an opt-in rvt-ifc --family-extrusions (#156) (RE-327) - #1342

Merged
DrunkOnJava merged 26 commits into
mainfrom
re/156-family-extrusions
Nov 4, 2026
Merged

DrunkOnJava merged 26 commits into
mainfrom
re/156-family-extrusions

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

Rebuilds a family's extrusions from their own sketch curve records (sketch curves, closed loops, extrusion parameters, solids: the chain Discussion #112 reports) and measures them against the mesh Revit saved for each form. Adds the opt-in rvt-ifc --family-extrusions, which draws a family instance from its family's extrusions where they reproduce its saved mesh. Draft: the export is measured on lines only (the arcs are an open call, below).

Motivation

#156 asks for an independent reproduction of the sketch-to-solid pipeline STE1200's team reported (85 of 86 extrusions of one family). RE-327's report is the evidence layer: where the records are on Revit 2015 to 2027, the rule that places the solid, and what is measured against what.

Changes

  • src/research/native_form_geometry.rs (new): a family file's own records without the project index (native_document refuses every .rfa); the sketch chain (GLine and GArc of the CurveElem records, loops, outlines and holes, the SketchPlane frame, the two Double parameters) and the solid; mesh_agreement.
  • src/research/native_family_forms.rs: family_records_in (family_records on any native release, optionally for given ids); family_records unchanged.
  • src/ifc/family_extrusions.rs (new), ExportOptions::with_family_extrusions and ExportNote::FamilyExtrusions in the shared export pipeline, and rvt-ifc --family-extrusions: off by default, implies --saved-meshes, default export unchanged. An instance whose body is its saved mesh becomes IfcExtrudedAreaSolids over IfcIndexedPolyCurve profiles of straight segments, placed by the instance's transform into the frame saved_meshes::attach puts the mesh in, where its family's extrusions reproduce that mesh (every vertex within 0.0001 ft of their surfaces, surface samples within 0.0011 ft of the mesh, volumes within the arcs' chord loss and 0.01%), checked for each instance on its own; otherwise it keeps the mesh, as it does for any instance with an arc in a profile. Only a family's ExtrusionElem, CurveElem and SketchPlane records are read: a family with a void, or an extrusion that does not rebuild (an ellipse, an unclosed sketch), draws nothing; other forms it holds and an unread Visible flag are not seen, and the per-instance check against the instance's own mesh is what refuses an instance they make differ. Revit 2024 to 2027 (measured on 2024 and 2025): an earlier file has no instance transform that reads (Einhoven: 11 unplaced, 0 replaced), and a reflected instance's is never read. A replaced family instance written as IfcSpace gets SpaceOutlineSource family_body, with its BodySource family_extrusions, instead of the stale saved_mesh. family_extrusions::attach_with_control checks a WalkerControl between its reads and for each instance, and run_export passes it. The line rvt-ifc prints splits the candidates into replaced, no rebuilt family, no transform, mesh too large, volume, vertices, surface, arc, unwritable and ambiguous.
  • tools/re/family_extrusion_bodies_vs_ifc.py: mesh_bodies_vs_ifc on the bodies whose BodySource is family_extrusions.
  • Reader bounds on hostile input: an arc whose angles are not finite, beyond 1e6 rad or spanning more than a turn is refused (Curve::range_along no longer overflows); a sketch of more than 4,096 curves is refused before it is read, and the quadratic comparison of a sketch with its stored loops runs only up to 256 curves; the polygon count is taken before any polygon is built; the vertex pass of mesh_agreement is bounded by the pair budget (a mesh over it is unchecked and keeps its body); a curve record seen in two partition copies is listed once.
  • docs/support-matrix.json (family-extrusion-bodies, experimental) and docs/evidence.md rows for the flag.
  • probes/examples/probe_re327_family_extrusions.rs, reports/element-framing/RE-327-family-extrusions.md, addenda in docs/format-reconnaissance.md and docs/status.md, the flag in README.md, docs/compatibility.md and docs/supported-profile.md, changelog fragments (research/ and added/).

Testing

Unit tests are banned in this repository: none added. The probe and the Measure runs are the end-to-end evidence; nothing was built or run locally.

  • tools/check-local.sh passes: run by CI on this PR (nothing is built locally). cargo fmt --all, tools/release/changelog.py check and tools/ci/api-doc-ids.py pass locally.
  • Verified end to end on real Revit files: the family corpus (phi-ag/rvt, 12 releases) and Autodesk's 58 sample projects (2015 to 2027, fetched for the run, never stored); the numbers and the script are in the report. The probe at the head aaa38de8: run 41805344172.
  • The default export is unchanged: run 41805327625 (aaa38de8, -f base=main -f holdout=true -f nordic=true, core-interior re1-* einhoven nordic-office-* holdout-* spent-*): 29 models with a hash on both sides, 29 the same, none moved, the 18 held-out models and the spent pair included (hashes only). The unfiltered run at b13be61a (41801584312) had 105 the same, none moved, and the six held-out models on the head side only, which this run supplies. Runs 41808993073 (b482eba2), 41811173603 (0b286d83) and 41813677577 (9f3814f6, with main at 999fc7b3 merged in) repeat it: 29 of 29 the same, each. Run 41816308266 (9412048f, the head) takes every model (-f base=main -f nordic=true -f r2025=true -f samples=true -f holdout=true -f families=true -f scorers=none): 111 with a hash on both sides, 111 the same, none moved.
  • The flag against Revit's own exports, three runs on the same ten models against 41805339819 (--saved-meshes alone), every IFC scorer plus family_extrusion_bodies_vs_ifc:
    • First, 41805333248 (aaa38de8, arcs drawn as arcs): 335 bodies replaced (Core Interior 37, the BIM4LCA office as built and at permit 129 each, its two terrain variants 11 each, RE1 Architecture 8, Electrical 8, Mechanical 1, Plumbing 1). The body scorer matched 251: 250 have Revit's vertices within 0.001 ft of rvt-rs's surface (most within 1e-5 ft), and one, RE1 Architecture's 'Dispenser, Toilet Paper' (element 360331), has them 0.001439 ft away (0.0009143 ft as its saved mesh): a blocker under the saved-mesh bar. The other 84 are family instances written as spaces, scored by space_profiles_vs_ifc. Every scorer row was the baseline's or better (the office files' bodies within 0.01% of Revit's volume 1,547 and 1,633 to 1,625 and 1,711), but for that one.
    • Second, 41808965272 (b482eba2): the export's tolerances narrowed to the sample projects' own (1e-4 ft at a vertex, 1.1e-3 ft at a surface sample, the chord loss and 0.01% in volume, from 5e-4 ft, 1.5e-3 ft and 1%). The same 335 bodies, the dispenser unchanged at 0.001439 ft: the extrusions agree with its saved mesh to 1e-4 ft, so the tolerances were not the cause. The volumes say what is: Revit's export is a coarse tessellation of arcs of its own, and where its vertices fall at other angles than ours it is up to a chord's sagitta off (an inference, not a measurement of the dispenser's profile).
    • Third, 41811170320 (0b286d83), repeated at the head 9412048f by 41816314683 after the review fixes with the same result: an instance with an arc in a profile keeps its mesh. 64 bodies are replaced (Core Interior 37, each office file 9, RE1 Architecture 6, Electrical 2, Mechanical 1) and all 64 pass "ref on ours"; every combined row of mesh_bodies_vs_ifc and saved_meshes_vs_ifc equals the baseline's in every column, and every other scorer, space_profiles_vs_ifc included, is identical. Nothing got worse and, with the arcs out, nothing got better. It leaves out 271 of the first run's 335 (the office files 120 each, the terrain files 11 each, Architecture 2, Electrical 6, Plumbing 1), of which 270 held the bar and gained what the first run shows.
  • Export time: one export of each model at the same time as the others, so load as much as code; the spread between three flag runs of the same model (Electrical 3,491, 2,714 and 4,500 ms against 3,282 without the flag) is as large as any difference the flag makes. No slowdown that matters.
  • Decision for the maintainer: whether arcs come back (follow-up Family extrusions: draw arc profiles again so every replaced body meets ref on ours (RE-327) #1346, milestone 0.15.0). Options not run: arcs as short sub-arcs (a chord within about 2.5e-4 ft), which bounds "ref on ours" whatever the phase of Revit's tessellation but gives the first run's gains back, or starting each loop where the extrusion record's stored loops start, which is a guess about Revit's order.

Measured against the saved meshes (the probe at aaa38de8, run 41805344172):

  • Family corpus: 24 of 24 extrusions (2 on each of 12 releases) within 0.001 ft; volume ratios 1.00009 (tabletop) and 1.00739 (four legs).
  • Sample projects: 9,587 extrusions in loaded families' documents, 9,423 built, 6,172 with a complete saved mesh and all 6,172 match (volume 1%, bounding box, mesh vertices and surface samples 0.01 ft): 6,093 with the plane's normal as its matrix gives it, 79 with the normal reversed. The 79 share one signature (a down-facing sketch plane, not flipped, whose extrusion reads m_alwaysRefPlaneNorm false): the rule was found on those 79 and is not held out, and it runs by default in the reader; what tests it is the export, which checks every instance against its own mesh. One up-facing flipped plane that differed is refused, and refusing an unread m_flipZ cost none of the 6,172. 29 partial meshes are outside the verdict; 3,222 built forms have no mesh (902 voids); 164 are not built (137 ellipses, 26 open sketches, the flipped plane).
  • The matrix's columns are the plane's axes; a flipped plane's m_flipZ applies.
  • VarSketch is refused on Revit 2015 to 2017 (VarParam::m_pSubst, RE-323 §5): a measured negative that the rebuild does not depend on.
  • Not reproduced: the reported 85 of 86 is on a Revit 2014 file, outside the native releases (native record framing is unvalidated for Revit 2014).

Audit-honesty checklist

  • README / docs reflect the current state: the flag is opt-in, implies --saved-meshes, and its measured state (one arc-bearing body failed the bar, so arcs keep the mesh) is in the report, docs/status.md and docs/supported-profile.md.
  • Changelog fragments: changelog.d/research/327-family-extrusions.md, changelog.d/added/327-family-extrusions-flag.md.
  • New limitations are in the report (§5, §8) and the code: arcs in a profile, ellipses, open sketches, sweeps, revolutions, blends, voids, a down-facing plane tilted off -z, parametric instances (each instance is checked against its own mesh).
  • Commit messages describe what and why. No emojis. No private paths.
  • RE finding: a reproducible probe under probes/examples/ and a dated addendum to docs/format-reconnaissance.md are included.

Legal and contribution hygiene

  • I agree this work is licensable under Apache-2.0.
  • The changes in this PR are based on public byte observations of Autodesk's published sample families and projects (the phi-ag/rvt corpus and Autodesk's sample projects), the class and field names of each file's own Formats/Latest, prior public reverse-engineering work (Discussion Set of findings #112: STE1200's team and jakobhirn-bit), and buildingSMART's IFC4 specification. I have not used Autodesk SDK source, ODA SDK source, leaked internal documentation, NDA material, or decompiled internal Revit implementation code beyond public symbol exports, and I have not copied or translated code from revit-ifc.
  • No test fixtures; nothing vendored. The corpus files are fetched for a run and never stored.

Breaking changes

None. rvt::ifc::family_extrusions is a new public module and ExportNote and ExportOptions (both #[non_exhaustive]) gain a variant and a field; the default export is unchanged.

Screenshots or output samples

The per-form lines and the tallies are in each run's family-<file>/probe.txt and sample-<file>/probe.txt. Reproduce the probe: gh workflow run measure.yml --ref main -f ref=aaa38de808f1731acf6f6a6dace59904f873335b -f base=none -f probe=probe_re327_family_extrusions -f families=true -f samples=true -f sample_years="2015 2027" -f scorers=none -f models=-. The flag run's command is in the report's §9.

Related issues

Refs #156. Follow-up for the arcs: #1346 (milestone 0.15.0). Discussion #112. Credit: STE1200's team (the chain and the unit trap) and jakobhirn-bit.

… the project index, and a second discovery probe (#156) (RE-327)
…urve records and measure them against the saved meshes (#156) (RE-327)
… each extrusion's profile is projected into its sketch plane's frame (#156) (RE-327)
…d the probe records what orients a sketch plane's normal (#156) (RE-327)
…s by where they lie, and the probe records each plane's normal and each open loop's gaps (#156) (RE-327)
…ts family's own extrusions where they reproduce its saved mesh, and RE-327's report (#156) (RE-327)
…own-facing plane that reads no reference normal is refused, and the flag is documented (#156) (RE-327)
…ould land

# Conflicts:
#	docs/format-reconnaissance.md
…c line sums to its candidates, an up-facing flipped plane is refused, and a scorer for the extrusion bodies (#156) (RE-327)
… so clippy's doc_lazy_continuation passes (#156) (RE-327)
…wn tolerances: chord loss for volume, 1e-4 ft for vertices, 1.1e-3 ft for surface samples (#156) (RE-327)
…ntity and flag runs, and the one body that failed the saved-mesh bar (#156) (RE-327)
… its mesh, since Revit's own arc tessellation can be out of phase with ours by 0.0014 ft (#156) (RE-327)
@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 4, 2026 10:29
…'s outline source, and bounds hostile sketches and meshes (#156) (RE-327)
…se as an inference, the family-level check, the figures and the matrix rows (#156) (RE-327)
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) November 4, 2026 11:54
@DrunkOnJava
DrunkOnJava merged commit a111351 into main Nov 4, 2026
29 checks passed
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