Skip to content

Show the family types of an .rfa page and compute them in the page - #100

Merged
mahach666 merged 9 commits into
mainfrom
rfa-family-types
Dec 4, 2026
Merged

mahach666 merged 9 commits into
mainfrom
rfa-family-types

Conversation

@mahach666

@mahach666 mahach666 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

What changes and why

An HTML page of a Revit family (.rfa) should show the types of the family and let the reader switch between them. This is the viewer side of IOExtend/RvtIO#358.

  • ViewerDocument.FamilyTypes carries the types and their parameters. With two or more types the viewer opens a Family type panel; choosing a type shows its geometry and parameters, and selection, measurement, sections and fitting see the chosen type only. A type without geometry says why. Viewer JSON, .ivmesh and --add outputs keep the saved type only, and the CLI says so.
  • A family page computes a type when it is chosen, with the program RvtIO.Scene gives (ViewerFamilyTypes.Program), so the page does not grow with the number of types. --bake-family-types stores the meshes of every type instead. The program starts at the first change of type; until it is ready the panel is busy and then shows the type chosen last. Such a page holds no points and no lines (a document with them is refused), since a computed type replaces the geometries of the page.
  • A family page is shaded as Revit shades one, keeps float32 positions, and keeps coinciding faces of two parts apart by a depth bias.

How the generated HTML changes: the page embeds the rebuilt viewer script and the template has a place for the family program. A family page with a program holds two more script blocks. Pages of other documents hold no program and are meant to be written and drawn as before.

Not ready to merge

How it was checked

  • dotnet build IOViewer.slnx -c Release has no warnings
    • With a local build of the RvtIO.Scene package: 0 warnings, 0 errors. It does not build with the version pinned now.
  • dotnet test IOViewer.slnx -c Release passes
    • With the local package, after merging main: 269 passed, 1 skipped, on net8.0 and net10.0. It does not build with the version pinned now.
    • Viewer, after merging main: npm run build leaves dist/viewer.js as committed; npm test 230 passed; the whole Chromium end-to-end set passed (191). Firefox was not run.
  • Generated HTML and JSON for the same inputs are unchanged, or the differences are listed and intended
    • Not compared file by file for documents that are not families.
  • No customer models, personal data or vendor code is added; new third-party code is listed in THIRD-PARTY-NOTICES.md
    • No third-party code is added.

An HTML page of a Revit family carries its types (ViewerDocument.FamilyTypes):
their parameters, and for each type its meshes or the reason it has none.
With two or more types the viewer opens a Family type panel; choosing a type
shows its geometry and parameters, and selection, measurement, sections and
fitting see the chosen type only. Viewer JSON, .ivmesh and --add outputs keep
the saved type only and the CLI says so.

On such a page the vertex positions are written as float32 instead of on the
1/1024 m grid, which moved a vertex by up to half a millimetre, and each
material is drawn slightly nearer than the one before it. Faces of two parts
that coincide (a flange bore on the ring it sits on) no longer alternate
between the two parts per pixel. Other pages are written and drawn as before.
Revit shades a part with no material grey 127 and, in its shots of a
sample valve, a flange of material colour 120 comes out at 0.945 of it.
The viewer draws a part with no colour 200, a tone close to Revit's, so
the plain flange (0.6 of it) was much darker than in Revit. The colours
of a family page are now scaled by 200 / 127, which makes 120 into 189.
Pages of other documents and parts with no colour are not changed.
A page of a family is now lit by one light fixed to the view, applied to the
colour values of the screen and fitted to Revit's shots of a sample valve,
and a part with no material is grey 127; the colour gain of the previous
commit is gone. Highlight, tint and white mode keep the viewer's lights, since
the brighter formula would clip them.

The viewer also keeps the float32 positions of such a page. It snapped merged
vertices back to the 1/1024 m grid, which folded the narrow facets of circles
into dark lines on cylinders and speckle on cones.

Other pages are written and drawn as before.
The materials of a family page are told apart by a depth bias where their faces
coincide. Its part by slope moved a face seen at a grazing angle far more than
the others and drew end faces through the bore of a flange as thin dark lines
that Revit does not draw. The bias is now in units of the depth buffer only.

Without a graphics card some coinciding faces still show as dashes at a grazing
angle, most when the parts over them are hidden by hand.
A family page now holds the saved type and the program of RvtIO.Scene that
computes the others (ViewerFamilyTypes.Program), so it no longer grows with the
number of types. The CLI exports an .rfa this way; --bake-family-types stores
the meshes of every type as before.

The program starts at the first change of type. Until it is ready the panel is
busy and the page keeps what it shows, then shows the type chosen last. A type
the program refuses says why, and so does every type when the program cannot
start. A computed type replaces the geometry of the scene: hidden, highlighted
and tinted elements, the clipping and the order of the materials stay.

The release of RvtIO.Scene that has the program is not out yet, so
Directory.Packages.props is not changed.
Both sides are kept: the family types, and the CAD lines, annotations,
sheets and element table of main.

A computed family type replaces the geometries of the page, so a page that
computes its types now refuses lines as it refuses points. The chosen
annotation sheet stays when the geometry is replaced.
@mahach666
mahach666 marked this pull request as ready for review December 4, 2026 02:25
@mahach666
mahach666 merged commit 0e146b0 into main Dec 4, 2026
7 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