Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ RvtIO is a .NET library and command line tool that reads Autodesk Revit projects
- Reads elements, parameters, geometry, file metadata and project information.
- Queries elements through `FilteredElementCollector`.
- Exports IFC2X3 coordination view, with optional Revit parameters as property sets.
- Exports browser-ready 3D scenes as binary glTF 2.0 (`.glb`) or versioned `rvtio-scene/1` JSON with reusable meshes, instancing, materials and element metadata.
- Exports a single-file offline 3D HTML viewer (`.html`) with an embedded WebGL inspection app and zero external network dependencies.
- Writes compact JSON or a full JSON dump with every parameter and geometry.

## Install
Expand Down Expand Up @@ -57,7 +59,15 @@ Export IFC with Revit parameters as property sets:
rvtio project.rvt project.parameters.ifc --ifc-revit-parameters
```

A `.ifc` output path selects IFC. Any other output path selects JSON, which is compact by default. If the output path is omitted, the tool writes `output.json`. Diagnostics go to standard error.
Export a binary glTF 2.0 scene or a self-contained offline 3D HTML viewer:

```sh
rvtio project.rvt project.glb
rvtio project.rvt project.html --viewer-title "Project Review"
rvtio project.rvt project.scene.json
```

A `.ifc` output path selects IFC, `.glb` selects glTF 2.0, `.html`/`.htm` selects the standalone 3D HTML viewer, `.scene.json` (or `--scene-json`) selects the `rvtio-scene/1` JSON contract, and any other output path selects data JSON, which is compact by default. If the output path is omitted, the tool writes `output.json`. Diagnostics go to standard error. See [3D scene export and standalone HTML viewer](docs/scene-export.md) for the scene contract and viewer options.

Export the state of one project phase:

Expand Down
6 changes: 5 additions & 1 deletion docs/export-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ The report is one JSON object, UTF-8, property names in camelCase. `schema` name
| `elements.inTable`, `elements.decoded` | Rows of the element table, and those with a parsed record. `decodedFraction` is their quotient (1 for an empty table). |
| `issues[]` | Other findings that make a read `partial`, as `stream`, `code`, `detail`. The one code is `no-rows`: the element table decoded no row (a project always has elements, so the table did not decode). |
| `elements.undecoded[]` | Rows of the element table without a parsed record, as `class`, `reason`, `count`, `examples`. The class of an element that never decoded is `unknown`. |
| `export.format` | `ifc`, `json` (the compact export) or `json-full`. |
| `export.format` | `ifc`, `glb`, `html`, `scene-json`, `json` (the compact export) or `json-full`. |
| `export.considered`, `exported`, `skipped` | Parsed elements the export looked at, wrote, and left out, counted as the exporter counts them (`exported` counts elements, not product entities: for example, a roof element that writes two product entities, an `IfcRoof` and an `IfcSlab` with the same tag, counts once in `exported`, so the exported total can be below the number of product entities). `exportedFraction` is `exported / considered`. |
| `export.skippedByClass[]` | Every skipped element class with its reason, count and up to five element ids (`examples`), largest first. The counts add up to `export.skipped`. |

Expand All @@ -88,6 +88,10 @@ A level, a room and the topography that is written as the site are listed as ski

The compact export writes the rows of the element table: `block-only-record` and `record-outside-exact-element-table` are the two reasons an element is left out. The full dump (`--json-full`) writes every parsed element.

### Reasons of a scene or HTML viewer export

`block-only-record`, `group-template`, `record-outside-exact-element-table`, `owned-by-family-nonspatial`, `type-element`, `non-physical-category`, `no-project-phase-reference`, `outside-export-phase`, `filtered-out`, `filtered-by-element-id`, `filtered-by-category`, `filtered-by-predicate`, `no-geometry`.

## Scripting

```
Expand Down
6 changes: 4 additions & 2 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ dotnet tool install --global RvtIO.Cli
rvtio project.rvt project.ifc
```

A `.ifc` output path selects IFC. Any other output path selects JSON, which is compact by default.
A `.ifc` output path selects IFC, `.glb` selects a binary glTF 2.0 scene, `.html` / `.htm` selects a standalone 3D HTML viewer, and `.scene.json` (or `--scene-json`) selects the versioned `rvtio-scene/1` JSON contract. Any other output path selects data JSON, which is compact by default.

```sh
rvtio project.rvt project.glb
rvtio project.rvt viewer.html
rvtio project.rvt project.compact.json --compact-json
rvtio project.rvt project.full.json --json-full
rvtio project.rvt project.parameters.ifc --ifc-revit-parameters
```

Run `rvtio --help` for all options. The exit codes and the `--report` file are described in [Export report and exit codes](export-report.md).
Run `rvtio --help` for all options. Scene and viewer options are described in [Scene and HTML 3D viewer export](scene-export.md); the exit codes and the `--report` file are described in [Export report and exit codes](export-report.md).

## Library

Expand Down
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ RvtIO is a .NET library and command line tool that reads Autodesk Revit projects
- Reads elements, parameters, geometry, file metadata and project information.
- Queries elements through `FilteredElementCollector`.
- Exports IFC2X3 coordination view, with optional Revit parameters as property sets.
- Exports browser-ready 3D scenes as binary glTF 2.0 (`.glb`), versioned `rvtio-scene/1` JSON, or a self-contained offline 3D HTML viewer (`.html`).
- Writes compact JSON or a full JSON dump with every parameter and geometry.

The library targets .NET 8 and .NET 10, uses managed code only, and supports Windows, Linux and macOS.
Expand All @@ -17,6 +18,7 @@ The library targets .NET 8 and .NET 10, uses managed code only, and supports Win

- [Getting started](getting-started.md): install the tool or the package and run a first export.
- [Public API](public-api.md): the supported surface of the library.
- [Scene and HTML 3D viewer export](scene-export.md): `.glb`, `rvtio-scene/1` JSON and standalone `.html` 3D viewer options.
- [Export report and exit codes](export-report.md): how a complete export is told from a partial one.
- [API reference](api/RvtIO.yml): every public type, generated from the XML documentation.
- [Source on GitHub](https://github.com/IOExtend/RvtIO) and [DeepWiki](https://deepwiki.com/IOExtend/RvtIO) for an automatically generated overview of the repository.
Expand Down
6 changes: 5 additions & 1 deletion docs/public-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ extension and label helpers carry the ids and names stored in the file format.
| `IfcUnitFamily` | The length unit family an export of the current profile declares, by the length format of the project: `Metre` for metres and for metres and centimetres, `Foot` for feet, feet and fractional inches and US survey feet, `Millimetre` for millimetres, for every other format and for an unreadable one. The legacy profile always declares millimetres. |
| `CompactJsonExporter` | `Export(rvtPath, outputPath, readerOptions, options)` reads a file and writes the compact JSON. |
| `CompactJsonExportOptions` | `JsonClassNamePrefix`: text put in front of every class name in the `name` field. |
| `SceneExporter` | Builds a `ModelScene` (`Build`, `OpenAndBuild`), writes and reads the versioned `rvtio-scene/1` JSON (`ExportJson`, `LoadJson`), and writes binary glTF 2.0 `.glb` (`ExportGlb`); see [3D scene export](scene-export.md). |
| `HtmlViewerExporter` | Writes a single-file offline 3D HTML viewer (`Export`, `ExportToString`) embedding a `ModelScene` and WebGL viewer. |
| `SceneExportOptions`, `HtmlViewerOptions` | Filtering (`ElementIds`, `CategoryIds`, `ElementFilter`), metadata (`IncludeParameters`, `IncludeTypeParameters`, `IncludedParameterNames`, `MaxParametersPerElement`), coordinate (`ApplySharedCoordinates`, `IncludeGrids`, `IncludeRooms`), viewer (`Title`, `InitialTheme`, `ShowGridsByDefault`) and diagnostic (`SkipLog`, `DiagnosticOutput`) options. |
| `ModelScene` and scene records | `ModelScene`, `SceneMaterial`, `SceneMeshPrototype`, `SceneMeshInstance`, `SceneElement`, `ScenePropertyGroup`, `SceneProperty`, `SceneCategoryNode`, `SceneGridLine`, `SceneCompletenessSummary`, `SceneOmittedGroup` (`RvtIO.Scene`). |

## Diagnostics

The library never writes to the console. A diagnostic message is written only when the caller gives a `TextWriter`:
`RvtReaderOptions.DiagnosticOutput` for a read (and for `CompactJsonExporter.Export`), `IfcExporter.DiagnosticOutput` (or the
constructor argument) for an IFC export. The default is `null`, which is silent. The writer is scoped to the call that
constructor argument) for an IFC export, `SceneExportOptions.DiagnosticOutput` for a scene or HTML viewer export. The default is `null`, which is silent. The writer is scoped to the call that
received it, so concurrent calls with different writers do not mix.

The `rvtio` command line tool sets the writer to standard error.
126 changes: 126 additions & 0 deletions docs/scene-export.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
---
title: Scene and HTML 3D viewer export
---

# 3D scene export and standalone HTML viewer

`RvtIO` exports browser-ready 3D geometry and element metadata directly from `.rvt` projects and `.rfa` families in three forms:

1. **Binary glTF 2.0 (`.glb`)** — standard 3D asset with reusable meshes, per-instance transforms, PBR materials and element metadata in `node.extras`.
2. **Versioned scene JSON (`rvtio-scene/1`)** — compact JSON contract with Base64 typed-array mesh buffers, category hierarchy, grouped element properties, datum grids and completeness notes.
3. **Self-contained 3D HTML viewer (`.html`)** — single offline HTML file embedding the `rvtio-scene/1` payload and a zero-dependency WebGL viewer with no external network requests or CDN links.

## Command line

Export a binary glTF 2.0 scene:

```sh
rvtio project.rvt project.glb
```

Export a self-contained HTML viewer:

```sh
rvtio project.rvt project.html --viewer-title "Tower A - Architectural"
```

Export the `rvtio-scene/1` JSON contract:

```sh
rvtio project.rvt project.scene.json
rvtio project.rvt scene.json --scene-json --scene-pretty
```

Filter by category or element IDs, control exported metadata, or apply shared coordinates:

```sh
rvtio project.rvt envelope.html --scene-categories Walls,Windows,Doors,Roofs
rvtio project.rvt subset.glb --scene-ids 184201,184205 --scene-no-parameters
rvtio project.rvt site.glb --scene-shared-coordinates --scene-include-rooms
```

### Options

| Option | Effect |
| --- | --- |
| `--scene-json` | Write `rvtio-scene/1` JSON instead of the compact data JSON. Automatic when the output path ends with `.scene.json`. |
| `--scene-pretty` | Indent the `rvtio-scene/1` JSON output. |
| `--scene-categories <c1,c2,...>` | Include only the listed categories. Accepts numeric category IDs (`-2000011`), `BuiltInCategory` names (`OST_Walls`) or English category names (`Walls`). |
| `--scene-ids <id1,id2,...>` | Include only the listed Revit element IDs. |
| `--scene-no-parameters` | Omit element and type parameters from the scene and HTML viewer. |
| `--scene-parameter-names <p1,...>` | Include only parameters matching the listed names or captions. |
| `--scene-shared-coordinates` | Transform coordinates by `RevitFileInfo.SharedTransform` before computing the relative-to-center (`rtcOffset`) origin. |
| `--scene-include-rooms` | Export room volumes (`OST_Rooms`) as translucent 3D enclosures. |
| `--scene-no-grids` | Omit datum grid lines (`OST_Grids`). |
| `--glb-z-up` | Keep Revit right-handed Z-up coordinates in `.glb` instead of rotating the root node to glTF Y-up. |
| `--viewer-title <text>` | Set a custom document and header title in the HTML viewer. |
| `--viewer-theme <dark\|light>` | Set the initial color theme of the HTML viewer (default: `dark`). |

All scene exports participate in `--report <report.json>` (`export.format` is `glb`, `html` or `scene-json`) and respect `--raise-limits` and `--allow-partial`.

## Library API

```csharp
using RvtIO;
using RvtIO.BuiltIns;
using RvtIO.Scene;

var doc = RvtDocument.Open("project.rvt", new RvtReaderOptions
{
R22Layout = true,
SeparateFacesWithDistinctOpenings = true,
SystemFamilyNameLocale = "ENU",
});

var options = new HtmlViewerOptions
{
Title = "Project Review",
InitialTheme = "dark",
CategoryIds = new HashSet<int>
{
(int)BuiltInCategory.OST_Walls,
(int)BuiltInCategory.OST_Doors,
(int)BuiltInCategory.OST_Windows,
},
};

ModelScene scene = SceneExporter.Build(doc, options);
SceneExporter.ExportGlb(scene, "project.glb");
SceneExporter.ExportJson(scene, "project.scene.json", indented: true);
HtmlViewerExporter.Export(scene, "project.html", options);
```

`SceneExporter.OpenAndBuild(rvtPath, options)` and `HtmlViewerExporter.Export(rvtPath, outputPath, options)` open the file with 3D geometry decoding (`R22Layout = true`) enabled by default.

## `rvtio-scene/1` JSON contract

The scene JSON is a single UTF-8 object with `camelCase` property names and `"schema": "rvtio-scene/1"`. Additive properties may be introduced within `rvtio-scene/1`; breaking changes increment the schema version.

| Property | Meaning |
| --- | --- |
| `schema` | Always `"rvtio-scene/1"`. |
| `title` | Human-readable model title. |
| `units` | `"m"` (metres). |
| `coordinateSystem` | `"right-handed-z-up"`. |
| `rtcOffset` | `[x, y, z]` double-precision origin offset in metres. Add `rtcOffset` to any scene coordinate to recover world metres: $P_{\text{world}} = P_{\text{scene}} + \text{rtcOffset}$. |
| `sharedTransform` | Optional 12-double `[basisX(3), basisY(3), basisZ(3), originMetres(3)]` internal-to-shared transform when present in the file. |
| `boundsMin`, `boundsMax` | `[x, y, z]` bounding box of the scene in RTC metres. |
| `materials[]` | `{ index, revitMaterialId?, name, color: [r,g,b], opacity, metallic, roughness, doubleSided }`. |
| `meshes[]` | Reusable indexed triangle prototypes: `{ index, sourceSymbolId?, isMirroredVariant, vertexCount, triangleCount, indexType ("uint16"\|"uint32"), localBoundsMin, localBoundsMax, positionsB64, normalsB64, indicesB64 }`. `positionsB64` and `normalsB64` are little-endian IEEE 754 `Float32Array` bytes (`vertexCount * 3` floats); `indicesB64` is little-endian `Uint16Array` or `Uint32Array` (`triangleCount * 3` indices). |
| `instances[]` | Placed mesh occurrences: `{ meshIndex, elementIndex, elementId, materialIndex, matrix, boundsMin, boundsMax }`, where `matrix` is a 16-float column-major 4x4 affine matrix in RTC metres. |
| `elements[]` | Exported physical elements: `{ id, uniqueId?, name, category, categoryId?, familyName?, typeName?, level?, hostId?, isInstanced, instanceIndices, propertyGroups: [{ group, properties: [{ name, value }] }] }`. |
| `categories[]` | Category tree nodes: `{ category, categoryId?, elementIndices }`. |
| `grids[]` | Datum grid segments in RTC metres: `{ id, name, start: [x,y,z], end: [x,y,z] }`. |
| `completeness` | `{ totalElements, consideredElements, exportedElements, instancedElements, reusableMeshCount, instanceCount, vertexCount, triangleCount, isPartialGeometry, notes[], omittedGroups: [{ code, reason, count }] }`. |

### Precision and instancing guarantees

- **Relative-to-center (RTC) coordinates**: Models located more than 100 m from the origin (such as georeferenced shared coordinates) automatically shift their scene origin to the double-precision bounding-box center stored in `rtcOffset`, preventing 32-bit `Float32` vertex jitter in WebGL and glTF viewers.
- **Reusable family symbol meshes**: Repeated `FamilyInstance` placements share a single `SceneMeshPrototype` in `meshes[]` (and a single glTF `mesh` in `.glb`) placed by per-instance 4x4 transforms.
- **Mirrored instances**: Instances whose placement transform has negative determinant ($\det(M) < 0$) reference a dedicated mirrored prototype variant (`isMirroredVariant: true`) with reversed triangle index winding `(i0, i2, i1)` so counter-clockwise front faces and outward `(M^{-1})^T` normals are preserved in standard glTF 2.0 and WebGL pipelines.

## Standalone HTML viewer capabilities and security

- **Navigation**: Orbit (left-drag), pan (right-drag or Shift + drag), cursor-targeted zoom (wheel), fit-to-model / fit-to-selection (`F`), orthographic/perspective toggle (`O`), and an interactive 3D ViewCube (`Top`, `Bottom`, `Front`, `Back`, `Left`, `Right`, `Home`).
- **Inspection & filtering**: 3D raycast picking with selection highlight, category hierarchy browser with visibility toggles, live text search across element names/IDs/categories/types/levels, `Hide` (`H`), `Isolate` (`I`), `Show All` (`Esc` / button), grouped property inspector, 6-axis interactive section box, datum grid toggle (`G`), 3D point-to-point distance measurement (`M`), theme toggle, and a model completeness summary dialog.
- **Offline & XSS safety**: Zero external scripts, stylesheets, fonts or images are referenced. All embedded JSON escapes `<`, `>`, `&` (`\u003C`, `\u003E`, `\u0026`) so `</script>` payloads in untrusted model strings cannot break out of `<script type="application/json">`, `<title>` is HTML-encoded, and the viewer UI renders every model string exclusively via DOM `.textContent`.
2 changes: 2 additions & 0 deletions docs/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
items:
- name: Public API
href: public-api.md
- name: Scene and HTML 3D viewer export
href: scene-export.md
- name: Export report and exit codes
href: export-report.md
- name: Coverage report
Expand Down
Loading