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
7 changes: 4 additions & 3 deletions THIRD-PARTY-NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ THE SOFTWARE.

## IOViewer.Cli tool package

The `IOViewer.Cli` tool package reads IFC and Revit files through the engine adapters, so besides `IOViewer` and
`IOScene` (MIT, copyright (c) 2026 mahach666) it ships the assemblies listed below. The `IOViewer` library package
references none of them.
The `IOViewer.Cli` tool package reads IFC, Revit and Navisworks cache files through the engine adapters, so besides
`IOViewer` and `IOScene` (MIT, copyright (c) 2026 mahach666) it ships the assemblies listed below. The `IOViewer`
library package references none of them.

| Component | Use | License |
|---|---|---|
| [IfcIO](https://github.com/IOExtend/IfcIO) 0.11.1 and IfcIO.Scene 0.11.1 | read IFC files into a scene | MIT, copyright (c) 2026 IfcIO contributors |
| [NwcIO](https://github.com/IOExtend/NwcIO) 0.13.0 and NwcIO.Scene 0.13.0 | read Navisworks caches into a scene | MIT, copyright (c) 2026 mahach666 |
| [RvtIO](https://github.com/IOExtend/RvtIO) 0.4.0 and RvtIO.Scene 0.4.0 | read Revit files into a scene | MIT, copyright (c) 2026 mahach666 |
| .NET runtime libraries (DeflateManaged sources, compiled into RvtIO) | managed inflate implementation adapted for tolerant decoding | MIT, copyright (c) .NET Foundation and Contributors |
| [OpenMcdf](https://github.com/openmcdf/openmcdf) 3.4.0, used by RvtIO | reads the compound file container of Revit files | MPL-2.0, copyright (c) 2010-2026 Federico Blaseotto, Jeremy Powell |
Expand Down
3 changes: 2 additions & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ ioviewer model.glb -o viewer.html
# and an error (elements may be missing) gives exit code 4 after the output is written
ioviewer model.ifc
ioviewer model.rvt
ioviewer model.nwc
ioviewer model.nwc --json model.viewer.json

# Launch local preview server and open in default browser
ioviewer model.glb --serve
```

The direct `.nwc` command is available in CLI builds from this repository. Published `IOViewer.Cli` 0.3.1 uses the
[IOScene JSON handoff](#navisworks-cache) for Navisworks models.
The CLI reports `.nwd` and `.nwf` as unsupported input formats and exits with code 3.

## C# API usage

Expand Down
51 changes: 46 additions & 5 deletions tests/IOViewer.Tests/ModelAndCliIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,27 +410,39 @@ public void Cli_ConvertIfcToHtml_ReadsTheModelThroughIfcIO()
}

[Fact]
public void Cli_ConvertNwcToHtml_ReadsTheModelThroughNwcIO()
public void Cli_ConvertNwcToHtml_ReportsAdapterWarningsAndWritesBothOutputs()
{
string input = Path.Combine(Path.GetTempPath(), $"test_model_{Guid.NewGuid():N}.nwc");
string html = Path.ChangeExtension(input, ".html");
string json = Path.ChangeExtension(input, ".json");
using var errors = new StringWriter();
var originalError = Console.Error;
try
{
var root = new NwcNode { Id = 0, Name = "Model", Class = "Model" };
root.Children.Add(new NwcNode { Id = 1, Name = "Test layer", Class = "LcRevitLayer", Tag = 52, Parent = root });
var leaf = new NwcNode { Id = 1, Name = "Test slab", Class = "Leaf", Tag = 22, Parent = root };
leaf.Properties.Add(new NwcPropertyRecord { FirstInt = 1, Tag = 52, Name = "Comment", Class = "Test", ValueType = 4, Value = "Sample" });
root.Children.Add(leaf);
NwcDocument.Create(
new NwcFileInfo { LoaderPlugin = "LcNwcLoaderPlugin:lcldrevit" }, rootNode: root).Save(input);
Console.SetError(errors);

Assert.Equal(0, Program.Main([input, "--json", json]));
Assert.Contains("Warning: properties-outside-tabs:", errors.ToString());
var scene = JsonViewerImporter.Load(json).Scene;
Assert.Empty(scene.Validate());
Assert.Equal(Path.GetFileName(input), Assert.Single(scene.Models).Key);
Assert.Contains(scene.Elements, element => element.Name == "Test layer");
Assert.True(File.Exists(html));
var model = Assert.Single(scene.Models);
Assert.Equal(Path.GetFileName(input), model.Key);
Assert.Equal("nwc", model.SourceFormat);
Assert.Contains(scene.Elements, element => element.Name == leaf.Name);

var view = ViewerHtml.Parse(File.ReadAllText(html));
Assert.Contains(view.Meta.GetProperty("elements").EnumerateArray(),
element => element.GetProperty("name").GetString() == leaf.Name);
}
finally
{
Console.SetError(originalError);
File.Delete(input);
File.Delete(html);
File.Delete(json);
Expand Down Expand Up @@ -462,6 +474,35 @@ public void Cli_MalformedNwc_ReportsLoadFailureWithoutWritingHtml()
}
}

[Theory]
[InlineData(".nwd")]
[InlineData(".nwf")]
public void Cli_UnsupportedNavisworksExtension_ReportsLoadFailureWithoutWritingOutputs(string extension)
{
string input = Path.Combine(Path.GetTempPath(), $"test_model_{Guid.NewGuid():N}{extension}");
string html = Path.ChangeExtension(input, ".html");
string json = Path.ChangeExtension(input, ".json");
using var errors = new StringWriter();
var originalError = Console.Error;
try
{
File.WriteAllBytes(input, []);
Console.SetError(errors);

Assert.Equal(3, Program.Main([input, "--json", json]));
Assert.Contains($"Unsupported input file extension: '{extension}'", errors.ToString());
Assert.False(File.Exists(html));
Assert.False(File.Exists(json));
}
finally
{
Console.SetError(originalError);
File.Delete(input);
File.Delete(html);
File.Delete(json);
}
}

[Fact]
public void Cli_AdapterDiagnostics_AreReportedOncePerSeverityAndKind()
{
Expand Down
Loading