Skip to content
Merged
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
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@ API between minor releases.

## [Unreleased]

### Added

- The CLI opens Revit families (`.rfa`) through `RvtIO.Scene`. When some of a family's geometry cannot be read, it
prints `Warning: Family geometry is incomplete.` and the HTML page shows an **Incomplete geometry** banner. Viewer
JSON keeps the mark in `ViewerDocument.GeometryIncomplete`.
- An HTML page of a family carries its types (`ViewerDocument.FamilyTypes`): their parameters, and for each type its
meshes or the reason it has none. Viewer JSON, `.ivmesh` and `--add` outputs keep the saved type only, and the CLI
prints `Warning: Family types are not carried to this output.`
- With two or more types, the viewer opens a **Family type** panel. Choosing a type shows its geometry and parameters,
or says why it has no geometry; selection, measurement, sections and fitting see the chosen type only.
- On a page with family types, the vertex positions are written as float32 and the viewer keeps them: on the 1/1024 m
grid a vertex moved by up to half a millimetre and the narrow facets of circles folded into dark lines. Each material
is drawn slightly nearer than the one before it, by units of the depth buffer, so that faces of two parts that coincide
(a flange bore on the ring it sits on) do not alternate between the two per pixel. The later material shows on a shared
face. Without a graphics card some such faces still show as dashes at a grazing angle.
- A page with family types is shaded like Revit's shaded view, with a light fixed to the view that was fitted to
Revit's pictures of a family, and a part with no material is grey 127. Highlight, tint and white mode look as on
other pages. Other pages are written and drawn as before.

## [0.4.4] - 2026-12-03

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageVersion Include="SkiaSharp" Version="$(SkiaSharpVersion)" />
<PackageVersion Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="$(SkiaSharpVersion)" />
<PackageVersion Include="PclIO.Scene" Version="0.1.3" />
<PackageVersion Include="RvtIO.Scene" Version="0.6.3" />
<PackageVersion Include="RvtIO.Scene" Version="0.7.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.12.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="4.0.1" />
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ ioviewer model.obj -o viewer.html
# Convert IFC, Revit or Navisworks models via the scene adapters
ioviewer model.ifc
ioviewer model.rvt -o viewer.html
ioviewer family.rfa -o family.html
ioviewer model.nwc -o viewer.html

# Convert and immediately preview in default web browser via built-in HTTP server
Expand Down Expand Up @@ -253,6 +254,7 @@ The documentation site with API references and guides is at <https://ioextend.gi
- The binary geometry block is assembled in memory before it is written, so it must stay below 2 GB.
- The [local clustered LOD viewer](docs/viewer-performance-baseline.md#real-ifc-and-rvt) supports element visibility and isolation, properties, filled sections, measurement snapping and display modes. Cluster packages carry authored review data, including saved views, linked models, grids, clashes, BCF and 4D, and [share exact repeated meshes](docs/viewer-performance-baseline.md#repeated-meshes). The [14.85 GB benchmark](docs/viewer-performance-baseline.md#1485-gb-federation-of-real-geometry) exercises page streaming across a federation of prepared IFC/RVT geometry.
- `HtmlViewerOptions.MaxMeshVertices` is unlimited by default. When a lower limit cuts the model, the viewer shows a banner with the number of meshes written.
- When some geometry of a Revit family (`.rfa`) cannot be read, the CLI prints `Warning: Family geometry is incomplete.` and the HTML page shows an **Incomplete geometry** banner. Viewer JSON keeps this mark. A clustered LOD page built from an `.ivmesh` export does not show the banner.
- The viewer needs WebGL 2; without it the page says so. If the browser drops the graphics context, the page shows a message asking to reload it.
- Transparent objects are sorted per chunk of merged geometry (or per cell of instanced copies), not per object, so overlapping transparent objects in the same chunk can blend in the wrong order.
- The viewer draws triangles only. Instances of line or point geometry are skipped, and the CLI prints a warning with their number.
Expand Down
7 changes: 7 additions & 0 deletions docs/public-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ The model data is the IOScene scene model, referenced by the `IOViewer` package.

- `ViewerDocument` holds the scene, startup clipping, and the model keys hidden at start in `HiddenModelKeys`.
`ShowHostInModelList` adds the first model to the Linked files controls so it can be hidden independently.
`GeometryIncomplete` marks a model whose importer could not read some geometry; the page shows a banner.
`FamilyTypes` lists the types of a Revit family for the HTML page; viewer JSON does not keep it.
- `ViewerFamilyTypes` holds the types next to the scene, which shows the type at `SavedIndex`. Each
`ViewerFamilyType` has its parameters (`ViewerFamilyValue`, with a null text when there is no exact one) and either
`Instances`, placing meshes of the scene or of `ViewerFamilyTypes.Geometries`, or a `RefusalCode`. A type whose
meshes exceed `HtmlViewerOptions.MaxMeshVertices` is listed with the code `too-large`. For a type computed
in the browser, the full limit applies to that type's own meshes when selected.
`ViewpointStates` adds optional state to saved cameras. `BcfTopics` holds imported summaries and viewpoints
with cameras already in scene coordinates. `Title` reads and writes `Scene.Title`.
- `ViewerSectionPlane`: Cutting plane defined by axis or custom normal. `Offset` is the signed distance in metres
Expand Down
39 changes: 39 additions & 0 deletions src/IOViewer.Cli/FamilyMap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using IOViewer.Model;
using RvtIO.Meshes;
using RvtIO.Scene;

namespace IOViewer.Cli;

// What a Revit family file's scene reports for the viewer.
internal static class FamilyMap
{
internal static void Apply(ViewerDocument document, RvtSceneResult result)
{
if (result.Diagnostics.Any(diagnostic => diagnostic.Code == "family-incomplete")) document.GeometryIncomplete = true;
if (result.FamilyTypes is not { } family) return;
document.FamilyTypes = new ViewerFamilyTypes
{
SavedIndex = family.SavedIndex,
Types = [.. family.Types.Select(type => new ViewerFamilyType
{
Name = type.Name,
Parameters = [.. type.Parameters.Select(parameter => new ViewerFamilyValue(parameter.Name, parameter.Text))],
Instances = type.Instances?.ToList(),
RefusalCode = type.Refusal?.Code,
RefusalDetail = type.Refusal?.Detail ?? "",
})],
Geometries = [.. family.Geometries],
Materials = [.. family.Materials],
Program = family.Program is { } program
? new ViewerFamilyProgram(RvtFamilyTypeProgram.Script, program.Data!, program.MaterialIds)
: null,
};
}

// Only the one HTML page of a single family carries its types: the viewer JSON and the cluster source hold the scene
// alone, and a document merged from several files has no single family.
internal static bool LeavesTypesOut(bool hasTypes, string outputPath, string? jsonPath, bool merged) =>
hasTypes && (merged || !string.IsNullOrEmpty(jsonPath)
|| outputPath.EndsWith(".json", StringComparison.OrdinalIgnoreCase)
|| outputPath.EndsWith(".ivmesh", StringComparison.OrdinalIgnoreCase));
}
45 changes: 34 additions & 11 deletions src/IOViewer.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ namespace IOViewer.Cli;
internal static class Program
{
private const string UsageText = """
Usage: ioviewer <input.glb|input.obj|input.json|input.ifc|input.ifczip|input.rvt|input.nwc|point-cloud> [output.html] [options]
Usage: ioviewer <input.glb|input.obj|input.json|input.ifc|input.ifczip|input.rvt|input.rfa|input.nwc|point-cloud> [output.html] [options]
ioviewer --help | --version

Generates standalone interactive 3D WebGL / HTML BIM & CAD model viewers
from 3D models (glTF/GLB, Wavefront OBJ, JSON, IFC, Revit, Navisworks) and point clouds
(E57, LAS/LAZ, PTG, ReCap, PLY, PCD, PTS, PTX, XYZ and more, read with PclIO). The HTML file
has no external dependencies and works offline. JSON input is viewer JSON,
an IOScene scene file or an IOViewer 0.1/0.2 snapshot. IFC (.ifc, .ifczip)
is read with IfcIO, Revit (.rvt) with RvtIO and Navisworks caches (.nwc)
is read with IfcIO, Revit (.rvt, .rfa) with RvtIO and Navisworks caches (.nwc)
with NwcIO. Conversion diagnostics are reported as warnings or errors.

Arguments:
<input> Path to input 3D model (.glb, .obj, .json, .ifc, .ifczip, .rvt, .nwc) or point cloud
<input> Path to input 3D model (.glb, .obj, .json, .ifc, .ifczip, .rvt, .rfa, .nwc) or point cloud
(.e57, .las, .laz, .ptg, .rcs, .rcp, .ply, .pcd, .pts, .ptx, .xyz, .csv, .sbf, .fls,
.lgsx, .lgs, .srf, .smf, .c3db, .bin, .pnts).
[output] Destination path for exported file (.html, .json or .ivmesh for clustered LOD).
Expand All @@ -53,6 +53,8 @@ Check gaps up to this distance instead. Requires --clash.
--no-properties Exclude element properties to reduce the file size.
--no-grids Exclude spatial grid lines.
--no-timeliner Exclude 4D TimeLiner schedule simulation.
--bake-family-types Store the meshes of every type of a Revit family (.rfa) in the page. By default
the page computes a type when it is chosen, so it does not grow with the types.
--json <file.json> Export the document as viewer JSON.
--serve [port] Start local HTTP preview server and open in default browser.
-h, --help Show this help message and exit.
Expand Down Expand Up @@ -99,6 +101,7 @@ public static int Main(string[] args)
bool includeProps = true;
bool includeGrids = true;
bool includeTimeLiner = true;
bool bakeFamilyTypes = false;
bool serve = false;
int servePort = 8080;

Expand Down Expand Up @@ -179,6 +182,9 @@ public static int Main(string[] args)
case "--no-timeliner":
includeTimeLiner = false;
break;
case "--bake-family-types":
bakeFamilyTypes = true;
break;
case "--json":
if (i + 1 >= args.Length)
{
Expand Down Expand Up @@ -257,18 +263,21 @@ public static int Main(string[] args)
var sw = Stopwatch.StartNew();
ViewerDocument doc;
int adapterCode;
bool hasTypes;
string sourcePath = inputPath;
try
{
doc = Load(inputPath, out var diagnostics);
doc = Load(inputPath, bakeFamilyTypes, out var diagnostics);
adapterCode = ExitCode(diagnostics);
hasTypes = doc.FamilyTypes is not null;
if (additional.Count > 0)
{
SceneFederation.SetInputPath(doc.Scene, inputPath);
foreach (var source in additional)
{
sourcePath = source.Path;
var input = Load(sourcePath, out diagnostics);
var input = Load(sourcePath, bakeFamilyTypes, out diagnostics);
hasTypes |= input.FamilyTypes is not null;
SceneFederation.Append(doc, input, sourcePath, source.Placement);
adapterCode = Math.Max(adapterCode, ExitCode(diagnostics));
}
Expand All @@ -286,6 +295,10 @@ public static int Main(string[] args)
return 3;
}

if (doc.GeometryIncomplete) Console.Error.WriteLine("Warning: Family geometry is incomplete.");
if (FamilyMap.LeavesTypesOut(hasTypes, outputPath, explicitJsonPath, additional.Count > 0))
Console.Error.WriteLine("Warning: Family types are not carried to this output.");

if (clashCategories is { } categories)
{
int clashCode = CheckClashes(doc.Scene, categories, clashClearance);
Expand Down Expand Up @@ -359,7 +372,7 @@ public static int Main(string[] args)
return adapterCode;
}

private static ViewerDocument Load(string path, out IReadOnlyList<SceneDiagnostic> diagnostics)
private static ViewerDocument Load(string path, bool bakeFamilyTypes, out IReadOnlyList<SceneDiagnostic> diagnostics)
{
diagnostics = [];
string ext = Path.GetExtension(path).ToLowerInvariant();
Expand All @@ -369,12 +382,12 @@ private static ViewerDocument Load(string path, out IReadOnlyList<SceneDiagnosti
".obj" => ObjViewerImporter.Load(path),
".json" => JsonViewerImporter.Load(path),
".ifc" or ".ifczip" => FromIfc(path, out diagnostics),
".rvt" => FromRvt(path, out diagnostics),
".rvt" or ".rfa" => FromRvt(path, bakeFamilyTypes, out diagnostics),
".nwc" => FromNwc(path, out diagnostics),
".e57" or ".las" or ".laz" or ".ptg" or ".rcs" or ".rcp" or ".ply" or ".pcd" or ".pts" or ".ptx"
or ".xyz" or ".csv" or ".sbf" or ".fls" or ".lgsx" or ".lgs" or ".srf" or ".smf" or ".c3db" or ".bin" or ".pnts"
=> FromPcl(path, out diagnostics),
_ => throw new NotSupportedException($"Unsupported input file extension: '{ext}'. Supported: .glb, .obj, .json, .ifc, .ifczip, .rvt, .nwc and point clouds (.e57, .las, .laz, .ptg, .rcs, .rcp, .ply, .pcd, .pts, .ptx, .xyz, .csv, .sbf, .fls, .lgsx, .lgs, .srf, .smf, .c3db, .bin, .pnts).")
_ => throw new NotSupportedException($"Unsupported input file extension: '{ext}'. Supported: .glb, .obj, .json, .ifc, .ifczip, .rvt, .rfa, .nwc and point clouds (.e57, .las, .laz, .ptg, .rcs, .rcp, .ply, .pcd, .pts, .ptx, .xyz, .csv, .sbf, .fls, .lgsx, .lgs, .srf, .smf, .c3db, .bin, .pnts).")
};
}

Expand Down Expand Up @@ -444,11 +457,21 @@ private static ViewerDocument FromIfc(string path, out IReadOnlyList<SceneDiagno
return FromScene(path, result.Document, diagnostics);
}

private static ViewerDocument FromRvt(string path, out IReadOnlyList<SceneDiagnostic> diagnostics)
// How a Revit file is read into a scene. One family is small, so its circles are drawn round and its page computes its
// types itself, unless asked to store the meshes of each; a project keeps the coarse sampling that keeps it light.
internal static RvtSceneOptions SceneOptions(string path, bool bakeFamilyTypes)
{
var family = string.Equals(Path.GetExtension(path), ".rfa", StringComparison.OrdinalIgnoreCase);
return new RvtSceneOptions { FineCircularEdges = family, FamilyTypeProgram = family && !bakeFamilyTypes };
}

private static ViewerDocument FromRvt(string path, bool bakeFamilyTypes, out IReadOnlyList<SceneDiagnostic> diagnostics)
{
var result = RvtSceneReader.Read(path);
var result = RvtSceneReader.Read(path, SceneOptions(path, bakeFamilyTypes));
diagnostics = result.Diagnostics;
return FromScene(path, result.Document, diagnostics);
var viewer = FromScene(path, result.Document, diagnostics);
FamilyMap.Apply(viewer, result);
return viewer;
}

private static ViewerDocument FromNwc(string path, out IReadOnlyList<SceneDiagnostic> diagnostics)
Expand Down
2 changes: 2 additions & 0 deletions src/IOViewer.Cli/SceneFederation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ internal static void Append(ViewerDocument target, ViewerDocument source, string
.Where(key => (source.ShowHostInModelList || key != sourceHost) && modelKeys.ContainsKey(key))
.Select(key => modelKeys[key]));
target.ShowHostInModelList = true;
target.GeometryIncomplete |= source.GeometryIncomplete;
target.FamilyTypes = null; // a merged scene has no single family whose types it could switch
to.Models.AddRange(from.Models);
to.Levels.AddRange(from.Levels);
to.Geometries.AddRange(from.Geometries);
Expand Down
1 change: 1 addition & 0 deletions src/IOViewer/Exporters/HtmlViewerExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ private static void Write(ViewerPayloadWriter payload, Stream stream)
("<!--IOVIEWER:META-->", payload.WriteMeta),
("<!--IOVIEWER:BIN-->", payload.WriteBin),
("<!--IOVIEWER:PROPS-->", payload.WriteProps),
("<!--IOVIEWER:PROGRAM-->", payload.WriteProgram),
];

var ordered = placeholders
Expand Down
4 changes: 3 additions & 1 deletion src/IOViewer/Exporters/HtmlViewerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public sealed class HtmlViewerOptions
/// <summary>
/// Maximum total number of mesh vertices written to the viewer (each mesh counts the vertices it draws).
/// When the model exceeds it, meshes are written in order while they fit, the rest are left out, and the
/// viewer shows that the model was truncated. Defaults to <see cref="int.MaxValue"/> (no limit).
/// viewer shows that the model was truncated. Meshes that only family types place come after the model's: a type
/// whose meshes do not all fit is listed without geometry. A type computed in the browser has the same limit
/// applied to its own meshes. Defaults to <see cref="int.MaxValue"/> (no limit).
/// </summary>
public int MaxMeshVertices { get; set; } = int.MaxValue;
}
4 changes: 4 additions & 0 deletions src/IOViewer/Exporters/JsonViewerExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ internal sealed class ViewerJsonFile
public List<string> HiddenModelKeys { get; set; } = [];
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool ShowHostInModelList { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool GeometryIncomplete { get; set; }
public Dictionary<string, ViewerViewpointState>? ViewpointStates { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<ViewerBcfTopic>? BcfTopics { get; set; }
Expand All @@ -95,6 +97,7 @@ internal sealed class ViewerJsonFile
SectionBox = doc.SectionBox,
HiddenModelKeys = doc.HiddenModelKeys,
ShowHostInModelList = doc.ShowHostInModelList,
GeometryIncomplete = doc.GeometryIncomplete,
ViewpointStates = doc.ViewpointStates is { Count: > 0 } ? doc.ViewpointStates : null,
BcfTopics = doc.BcfTopics is { Count: > 0 } ? doc.BcfTopics : null,
PointColors = doc.PointColors is { Count: > 0 } ? doc.PointColors : null,
Expand All @@ -112,6 +115,7 @@ internal sealed class ViewerJsonFile
SectionBox = SectionBox,
HiddenModelKeys = HiddenModelKeys,
ShowHostInModelList = ShowHostInModelList,
GeometryIncomplete = GeometryIncomplete,
ViewpointStates = ViewpointStates ?? [],
BcfTopics = BcfTopics ?? [],
PointColors = PointColors ?? [],
Expand Down
Loading
Loading