From 6d89863e1dfdf2b4eecf6a7d2c3de5675539d00f Mon Sep 17 00:00:00 2001
From: mahach666 <79989386+mahach666@users.noreply.github.com>
Date: Wed, 18 Nov 2026 04:49:15 +0300
Subject: [PATCH 1/3] Isolate the NwcIO frozen implementations
---
.github/workflows/ci.yml | 1 +
CONTRIBUTING.md | 14 +-
.../Clash}/NwcClash.cs | 0
.../Clash/NwcClashBcfExporter.cs | 0
.../Clash/NwcClashDetector.cs | 0
.../Clash/NwcClashGrouper.cs | 0
.../Clash/NwcClashMatrix.cs | 0
.../Clash/NwcClashTypes.cs | 0
.../Clash/NwcNwfManifest.cs | 0
.../Clash/NwcTriangleIntersection.cs | 0
.../Clash/NwcXmlClashSerializer.cs | 0
.../Diff/NwcDiffEngine.cs | 0
.../Diff/NwcDiffTypes.cs | 0
.../Export/BcfExporter.cs | 0
.../Export/GlbExporter.cs | 0
.../Export/HtmlClashReportExporter.cs | 0
.../Export/IfcExporter.cs | 0
.../Export/NwcElementGuid.cs | 0
.../Export/ObjExporter.cs | 0
.../Export/StepWriter.cs | 0
.../Grids/NwcGridIntersection.cs | 0
.../Grids/NwcGridLine.cs | 0
.../Grids/NwcGridSystem.cs | 0
.../Measure/NwcMeasureEngine.cs | 0
.../NwcAssembly.Compatibility.cs | 123 ++++++++++++++++++
.../NwcDocument.Compatibility.cs | 13 +-
.../NwcDocumentBuilder.Compatibility.cs | 16 +++
.../NwcIfcExportOptions.cs | 0
.../Sectioning/NwcMeshClipper.cs | 0
.../Sectioning/NwcViewpointBcfExporter.cs | 0
.../Sectioning/NwcXmlViewpointSerializer.cs | 0
.../Viewer/NwcHtmlViewerExporter.cs | 0
src/NwcIO/Model/NwcAssembly.cs | 123 ------------------
src/NwcIO/NwcDocument.cs | 13 +-
src/NwcIO/NwcDocumentBuilder.cs | 17 +--
src/NwcIO/NwcIO.csproj | 8 ++
36 files changed, 176 insertions(+), 152 deletions(-)
rename src/NwcIO/{Model => Compatibility/Clash}/NwcClash.cs (100%)
rename src/NwcIO/{Model => Compatibility}/Clash/NwcClashBcfExporter.cs (100%)
rename src/NwcIO/{Model => Compatibility}/Clash/NwcClashDetector.cs (100%)
rename src/NwcIO/{Model => Compatibility}/Clash/NwcClashGrouper.cs (100%)
rename src/NwcIO/{Model => Compatibility}/Clash/NwcClashMatrix.cs (100%)
rename src/NwcIO/{Model => Compatibility}/Clash/NwcClashTypes.cs (100%)
rename src/NwcIO/{Model => Compatibility}/Clash/NwcNwfManifest.cs (100%)
rename src/NwcIO/{Model => Compatibility}/Clash/NwcTriangleIntersection.cs (100%)
rename src/NwcIO/{Model => Compatibility}/Clash/NwcXmlClashSerializer.cs (100%)
rename src/NwcIO/{Model => Compatibility}/Diff/NwcDiffEngine.cs (100%)
rename src/NwcIO/{Model => Compatibility}/Diff/NwcDiffTypes.cs (100%)
rename src/NwcIO/{Internal => Compatibility}/Export/BcfExporter.cs (100%)
rename src/NwcIO/{Internal => Compatibility}/Export/GlbExporter.cs (100%)
rename src/NwcIO/{Internal => Compatibility}/Export/HtmlClashReportExporter.cs (100%)
rename src/NwcIO/{Internal => Compatibility}/Export/IfcExporter.cs (100%)
rename src/NwcIO/{Internal => Compatibility}/Export/NwcElementGuid.cs (100%)
rename src/NwcIO/{Internal => Compatibility}/Export/ObjExporter.cs (100%)
rename src/NwcIO/{Internal => Compatibility}/Export/StepWriter.cs (100%)
rename src/NwcIO/{Model => Compatibility}/Grids/NwcGridIntersection.cs (100%)
rename src/NwcIO/{Model => Compatibility}/Grids/NwcGridLine.cs (100%)
rename src/NwcIO/{Model => Compatibility}/Grids/NwcGridSystem.cs (100%)
rename src/NwcIO/{Model => Compatibility}/Measure/NwcMeasureEngine.cs (100%)
create mode 100644 src/NwcIO/Compatibility/NwcDocumentBuilder.Compatibility.cs
rename src/NwcIO/{ => Compatibility}/NwcIfcExportOptions.cs (100%)
rename src/NwcIO/{Model => Compatibility}/Sectioning/NwcMeshClipper.cs (100%)
rename src/NwcIO/{Model => Compatibility}/Sectioning/NwcViewpointBcfExporter.cs (100%)
rename src/NwcIO/{Model => Compatibility}/Sectioning/NwcXmlViewpointSerializer.cs (100%)
rename src/NwcIO/{Model => Compatibility}/Viewer/NwcHtmlViewerExporter.cs (100%)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index ff6ab63..7d428e5 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -32,6 +32,7 @@ jobs:
path: coverage/**/coverage.cobertura.xml
if-no-files-found: error
- run: dotnet pack NwcIO.slnx -c Release --no-build -o artifacts
+ - run: dotnet build src/NwcIO/NwcIO.csproj -c Release -p:BuildNativeCoreOnly=true --artifacts-path native-core-check
- uses: actions/upload-artifact@v7
with:
name: packages-${{ matrix.os }}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index b9d1f76..d4c2b2b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -26,13 +26,21 @@ Report security vulnerabilities privately through the **Security** tab.
## Library boundaries
The native reader, writer and JSON output follow the Navisworks file model.
-The frozen convenience methods on `NwcDocument` and `NwcAssembly` are in
-`src/NwcIO/Compatibility`. They keep their existing signatures and assembly
-so applications can continue using them while replacements are developed.
+The frozen exports, viewer, coordination and XML federation manifest live in
+`src/NwcIO/Compatibility`. The regular library keeps their signatures,
+namespaces and assembly identity. Binary NWF reading stays with the engine.
Keep new native-format operations with the reader or writer.
The CLI uses the public APIs of NwcIO and NwcIO.Scene. Command-specific
presentation, such as model labels in raycast output, belongs to the CLI.
+CI also compiles the native library with the compatibility sources excluded.
+Use a separate artifact path for this compile check. It keeps the regular
+build available for testing and produces no NuGet package.
+
+```sh
+dotnet build src/NwcIO/NwcIO.csproj -c Release -p:BuildNativeCoreOnly=true --artifacts-path ./artifacts/native-core-check
+```
+
## Test Fixtures
Tests requiring real Navisworks files are skipped automatically unless the environment variable `NWCIO_TEST_FILES` is set to a directory containing private test models. The repository ships no proprietary Navisworks models.
diff --git a/src/NwcIO/Model/NwcClash.cs b/src/NwcIO/Compatibility/Clash/NwcClash.cs
similarity index 100%
rename from src/NwcIO/Model/NwcClash.cs
rename to src/NwcIO/Compatibility/Clash/NwcClash.cs
diff --git a/src/NwcIO/Model/Clash/NwcClashBcfExporter.cs b/src/NwcIO/Compatibility/Clash/NwcClashBcfExporter.cs
similarity index 100%
rename from src/NwcIO/Model/Clash/NwcClashBcfExporter.cs
rename to src/NwcIO/Compatibility/Clash/NwcClashBcfExporter.cs
diff --git a/src/NwcIO/Model/Clash/NwcClashDetector.cs b/src/NwcIO/Compatibility/Clash/NwcClashDetector.cs
similarity index 100%
rename from src/NwcIO/Model/Clash/NwcClashDetector.cs
rename to src/NwcIO/Compatibility/Clash/NwcClashDetector.cs
diff --git a/src/NwcIO/Model/Clash/NwcClashGrouper.cs b/src/NwcIO/Compatibility/Clash/NwcClashGrouper.cs
similarity index 100%
rename from src/NwcIO/Model/Clash/NwcClashGrouper.cs
rename to src/NwcIO/Compatibility/Clash/NwcClashGrouper.cs
diff --git a/src/NwcIO/Model/Clash/NwcClashMatrix.cs b/src/NwcIO/Compatibility/Clash/NwcClashMatrix.cs
similarity index 100%
rename from src/NwcIO/Model/Clash/NwcClashMatrix.cs
rename to src/NwcIO/Compatibility/Clash/NwcClashMatrix.cs
diff --git a/src/NwcIO/Model/Clash/NwcClashTypes.cs b/src/NwcIO/Compatibility/Clash/NwcClashTypes.cs
similarity index 100%
rename from src/NwcIO/Model/Clash/NwcClashTypes.cs
rename to src/NwcIO/Compatibility/Clash/NwcClashTypes.cs
diff --git a/src/NwcIO/Model/Clash/NwcNwfManifest.cs b/src/NwcIO/Compatibility/Clash/NwcNwfManifest.cs
similarity index 100%
rename from src/NwcIO/Model/Clash/NwcNwfManifest.cs
rename to src/NwcIO/Compatibility/Clash/NwcNwfManifest.cs
diff --git a/src/NwcIO/Model/Clash/NwcTriangleIntersection.cs b/src/NwcIO/Compatibility/Clash/NwcTriangleIntersection.cs
similarity index 100%
rename from src/NwcIO/Model/Clash/NwcTriangleIntersection.cs
rename to src/NwcIO/Compatibility/Clash/NwcTriangleIntersection.cs
diff --git a/src/NwcIO/Model/Clash/NwcXmlClashSerializer.cs b/src/NwcIO/Compatibility/Clash/NwcXmlClashSerializer.cs
similarity index 100%
rename from src/NwcIO/Model/Clash/NwcXmlClashSerializer.cs
rename to src/NwcIO/Compatibility/Clash/NwcXmlClashSerializer.cs
diff --git a/src/NwcIO/Model/Diff/NwcDiffEngine.cs b/src/NwcIO/Compatibility/Diff/NwcDiffEngine.cs
similarity index 100%
rename from src/NwcIO/Model/Diff/NwcDiffEngine.cs
rename to src/NwcIO/Compatibility/Diff/NwcDiffEngine.cs
diff --git a/src/NwcIO/Model/Diff/NwcDiffTypes.cs b/src/NwcIO/Compatibility/Diff/NwcDiffTypes.cs
similarity index 100%
rename from src/NwcIO/Model/Diff/NwcDiffTypes.cs
rename to src/NwcIO/Compatibility/Diff/NwcDiffTypes.cs
diff --git a/src/NwcIO/Internal/Export/BcfExporter.cs b/src/NwcIO/Compatibility/Export/BcfExporter.cs
similarity index 100%
rename from src/NwcIO/Internal/Export/BcfExporter.cs
rename to src/NwcIO/Compatibility/Export/BcfExporter.cs
diff --git a/src/NwcIO/Internal/Export/GlbExporter.cs b/src/NwcIO/Compatibility/Export/GlbExporter.cs
similarity index 100%
rename from src/NwcIO/Internal/Export/GlbExporter.cs
rename to src/NwcIO/Compatibility/Export/GlbExporter.cs
diff --git a/src/NwcIO/Internal/Export/HtmlClashReportExporter.cs b/src/NwcIO/Compatibility/Export/HtmlClashReportExporter.cs
similarity index 100%
rename from src/NwcIO/Internal/Export/HtmlClashReportExporter.cs
rename to src/NwcIO/Compatibility/Export/HtmlClashReportExporter.cs
diff --git a/src/NwcIO/Internal/Export/IfcExporter.cs b/src/NwcIO/Compatibility/Export/IfcExporter.cs
similarity index 100%
rename from src/NwcIO/Internal/Export/IfcExporter.cs
rename to src/NwcIO/Compatibility/Export/IfcExporter.cs
diff --git a/src/NwcIO/Internal/Export/NwcElementGuid.cs b/src/NwcIO/Compatibility/Export/NwcElementGuid.cs
similarity index 100%
rename from src/NwcIO/Internal/Export/NwcElementGuid.cs
rename to src/NwcIO/Compatibility/Export/NwcElementGuid.cs
diff --git a/src/NwcIO/Internal/Export/ObjExporter.cs b/src/NwcIO/Compatibility/Export/ObjExporter.cs
similarity index 100%
rename from src/NwcIO/Internal/Export/ObjExporter.cs
rename to src/NwcIO/Compatibility/Export/ObjExporter.cs
diff --git a/src/NwcIO/Internal/Export/StepWriter.cs b/src/NwcIO/Compatibility/Export/StepWriter.cs
similarity index 100%
rename from src/NwcIO/Internal/Export/StepWriter.cs
rename to src/NwcIO/Compatibility/Export/StepWriter.cs
diff --git a/src/NwcIO/Model/Grids/NwcGridIntersection.cs b/src/NwcIO/Compatibility/Grids/NwcGridIntersection.cs
similarity index 100%
rename from src/NwcIO/Model/Grids/NwcGridIntersection.cs
rename to src/NwcIO/Compatibility/Grids/NwcGridIntersection.cs
diff --git a/src/NwcIO/Model/Grids/NwcGridLine.cs b/src/NwcIO/Compatibility/Grids/NwcGridLine.cs
similarity index 100%
rename from src/NwcIO/Model/Grids/NwcGridLine.cs
rename to src/NwcIO/Compatibility/Grids/NwcGridLine.cs
diff --git a/src/NwcIO/Model/Grids/NwcGridSystem.cs b/src/NwcIO/Compatibility/Grids/NwcGridSystem.cs
similarity index 100%
rename from src/NwcIO/Model/Grids/NwcGridSystem.cs
rename to src/NwcIO/Compatibility/Grids/NwcGridSystem.cs
diff --git a/src/NwcIO/Model/Measure/NwcMeasureEngine.cs b/src/NwcIO/Compatibility/Measure/NwcMeasureEngine.cs
similarity index 100%
rename from src/NwcIO/Model/Measure/NwcMeasureEngine.cs
rename to src/NwcIO/Compatibility/Measure/NwcMeasureEngine.cs
diff --git a/src/NwcIO/Compatibility/NwcAssembly.Compatibility.cs b/src/NwcIO/Compatibility/NwcAssembly.Compatibility.cs
index ecd3b19..93b42f3 100644
--- a/src/NwcIO/Compatibility/NwcAssembly.Compatibility.cs
+++ b/src/NwcIO/Compatibility/NwcAssembly.Compatibility.cs
@@ -6,6 +6,129 @@ namespace NwcIO.Model;
public sealed partial class NwcAssembly
{
+ /// Multi-discipline clash coordination matrix associated with the assembly.
+ public Clash.NwcClashMatrix? ClashMatrix { get; set; }
+
+ ///
+ /// Opens a federation manifest (.nwf.xml) and loads the .nwc/.nwd models it lists.
+ /// Relative paths are resolved under the manifest folder; an absolute path is tried as written first
+ /// and then by its trailing segments under the manifest folder. Backslashes in stored paths are read as
+ /// directory separators on every platform. Only the model list is read: viewpoints, sets, appearance
+ /// rules and clash tests of the manifest are not loaded.
+ /// Missing and unsupported entries are recorded on
+ /// and .
+ ///
+ /// The manifest is missing, or none of its models could be resolved.
+ public static NwcAssembly OpenManifest(string manifestPath, NwcReaderOptions? options = null)
+ => OpenManifest(manifestPath, options, null, default);
+
+ ///
+ /// Opens a federation manifest with cancellation and progress for each listed model.
+ ///
+ public static NwcAssembly OpenManifest(
+ string manifestPath,
+ NwcReaderOptions? options,
+ IProgress? progress,
+ CancellationToken cancellationToken)
+ {
+ ArgumentNullException.ThrowIfNull(manifestPath);
+ if (!File.Exists(manifestPath))
+ {
+ throw new FileNotFoundException($"Manifest file not found: {manifestPath}", manifestPath);
+ }
+
+ var manifest = Clash.NwcNwfManifest.Open(manifestPath);
+ var baseDir = Path.GetDirectoryName(Path.GetFullPath(manifestPath)) ?? ".";
+ var loadedDocs = new List();
+ var loadedPaths = new HashSet(OperatingSystem.IsWindows()
+ ? StringComparer.OrdinalIgnoreCase
+ : StringComparer.Ordinal);
+ var unresolved = new List();
+ var skipped = new List();
+
+ int processed = 0;
+ foreach (var modelPath in manifest.ModelPaths)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ progress?.Report(new NwcProgress("load-models", processed++, manifest.ModelPaths.Count));
+ var xref = new NwcXRef(modelPath.Replace('\\', Path.DirectorySeparatorChar), "");
+ if (!xref.TryResolve(baseDir, out string resolved))
+ {
+ unresolved.Add(xref);
+ continue;
+ }
+
+ if (!resolved.EndsWith(".nwc", StringComparison.OrdinalIgnoreCase) &&
+ !resolved.EndsWith(".nwd", StringComparison.OrdinalIgnoreCase))
+ {
+ skipped.Add(xref);
+ continue;
+ }
+
+ if (loadedPaths.Add(Path.GetFullPath(resolved)))
+ {
+ loadedDocs.Add(NwcDocument.Open(resolved, options, null, cancellationToken));
+ }
+ }
+
+ if (loadedDocs.Count == 0)
+ {
+ throw new FileNotFoundException(
+ $"No .nwc or .nwd models listed in manifest '{manifestPath}' could be resolved.");
+ }
+
+ progress?.Report(new NwcProgress("load-models", manifest.ModelPaths.Count, manifest.ModelPaths.Count));
+ string fileName = Path.GetFileNameWithoutExtension(manifestPath);
+ string assemblyName = fileName.EndsWith(".nwf", StringComparison.OrdinalIgnoreCase)
+ ? Path.GetFileNameWithoutExtension(fileName)
+ : fileName;
+ var assembly = Create(assemblyName, loadedDocs);
+ assembly.UnresolvedXRefs = unresolved;
+ assembly.SkippedXRefs = skipped;
+ return assembly;
+ }
+
+ /// Creates a Navisworks Federated Project Manifest (NWF) representation of this assembly.
+ public Clash.NwcNwfManifest ToNwfManifest()
+ {
+ var manifest = new Clash.NwcNwfManifest(Name);
+ for (int i = 0; i < Models.Count; i++)
+ {
+ var p = Models[i].GetLoadedPath();
+ if (string.IsNullOrEmpty(p))
+ {
+ p = Models[i].FileInfo.SourcePath;
+ }
+ if (!string.IsNullOrEmpty(p))
+ {
+ manifest.ModelPaths.Add(p);
+ }
+ }
+ manifest.SavedViewpoints.AddRange(SavedViewpoints);
+ manifest.Sets.AddRange(SelectionSets);
+ foreach (var model in Models)
+ {
+ if (model.AppearanceProfiler is not null)
+ {
+ manifest.AppearanceProfiler.Rules.AddRange(model.AppearanceProfiler.Rules);
+ }
+ }
+ manifest.ClashTests.AddRange(ClashTests);
+ return manifest;
+ }
+
+ /// Saves the assembly coordination manifest as a Navisworks NWF coordination file (.nwf.xml).
+ public void SaveNwf(string path)
+ {
+ var manifest = ToNwfManifest();
+ var directory = Path.GetDirectoryName(Path.GetFullPath(path))!;
+ for (var i = 0; i < manifest.ModelPaths.Count; i++)
+ {
+ manifest.ModelPaths[i] = Path.GetRelativePath(directory, manifest.ModelPaths[i]);
+ }
+ manifest.Save(path);
+ }
+
///
/// Applies an appearance profiler across all contributing models in the federated assembly.
///
diff --git a/src/NwcIO/Compatibility/NwcDocument.Compatibility.cs b/src/NwcIO/Compatibility/NwcDocument.Compatibility.cs
index 91726e0..5f5d8e0 100644
--- a/src/NwcIO/Compatibility/NwcDocument.Compatibility.cs
+++ b/src/NwcIO/Compatibility/NwcDocument.Compatibility.cs
@@ -4,14 +4,11 @@ namespace NwcIO;
public sealed partial class NwcDocument
{
- /// Applies an appearance profiler to colorize the document based on property rules.
- /// The total number of scene nodes and meshes whose appearance was overridden.
- public int ApplyAppearanceProfiler(Model.Appearance.NwcAppearanceProfiler profiler)
- {
- ArgumentNullException.ThrowIfNull(profiler);
- AppearanceProfiler = profiler;
- return profiler.Apply(this);
- }
+ /// Configured Clash Detective tests and results for this document.
+ public List ClashTests { get; } = [];
+
+ /// Spatial grid system (axes and levels) associated with the document.
+ public Model.Grids.NwcGridSystem? GridSystem { get; set; }
/// Exports the document appearance profiler rules to a Navisworks XML format (.xml).
public void ExportAppearanceProfilerXml(string path)
diff --git a/src/NwcIO/Compatibility/NwcDocumentBuilder.Compatibility.cs b/src/NwcIO/Compatibility/NwcDocumentBuilder.Compatibility.cs
new file mode 100644
index 0000000..2a89bba
--- /dev/null
+++ b/src/NwcIO/Compatibility/NwcDocumentBuilder.Compatibility.cs
@@ -0,0 +1,16 @@
+namespace NwcIO;
+
+public sealed partial class NwcDocumentBuilder
+{
+ private readonly List _clashTests = [];
+
+ /// Adds a Clash Detective test to the document.
+ public NwcDocumentBuilder AddClashTest(Model.Clash.NwcClashTest test)
+ {
+ ArgumentNullException.ThrowIfNull(test);
+ _clashTests.Add(test);
+ return this;
+ }
+
+ partial void AddConfiguredClashTests(NwcDocument document) => document.ClashTests.AddRange(_clashTests);
+}
diff --git a/src/NwcIO/NwcIfcExportOptions.cs b/src/NwcIO/Compatibility/NwcIfcExportOptions.cs
similarity index 100%
rename from src/NwcIO/NwcIfcExportOptions.cs
rename to src/NwcIO/Compatibility/NwcIfcExportOptions.cs
diff --git a/src/NwcIO/Model/Sectioning/NwcMeshClipper.cs b/src/NwcIO/Compatibility/Sectioning/NwcMeshClipper.cs
similarity index 100%
rename from src/NwcIO/Model/Sectioning/NwcMeshClipper.cs
rename to src/NwcIO/Compatibility/Sectioning/NwcMeshClipper.cs
diff --git a/src/NwcIO/Model/Sectioning/NwcViewpointBcfExporter.cs b/src/NwcIO/Compatibility/Sectioning/NwcViewpointBcfExporter.cs
similarity index 100%
rename from src/NwcIO/Model/Sectioning/NwcViewpointBcfExporter.cs
rename to src/NwcIO/Compatibility/Sectioning/NwcViewpointBcfExporter.cs
diff --git a/src/NwcIO/Model/Sectioning/NwcXmlViewpointSerializer.cs b/src/NwcIO/Compatibility/Sectioning/NwcXmlViewpointSerializer.cs
similarity index 100%
rename from src/NwcIO/Model/Sectioning/NwcXmlViewpointSerializer.cs
rename to src/NwcIO/Compatibility/Sectioning/NwcXmlViewpointSerializer.cs
diff --git a/src/NwcIO/Model/Viewer/NwcHtmlViewerExporter.cs b/src/NwcIO/Compatibility/Viewer/NwcHtmlViewerExporter.cs
similarity index 100%
rename from src/NwcIO/Model/Viewer/NwcHtmlViewerExporter.cs
rename to src/NwcIO/Compatibility/Viewer/NwcHtmlViewerExporter.cs
diff --git a/src/NwcIO/Model/NwcAssembly.cs b/src/NwcIO/Model/NwcAssembly.cs
index 13c334b..3344da8 100644
--- a/src/NwcIO/Model/NwcAssembly.cs
+++ b/src/NwcIO/Model/NwcAssembly.cs
@@ -45,9 +45,6 @@ public sealed partial class NwcAssembly
/// Selection Sets and Search Sets defined in the federated assembly.
public List SelectionSets { get; } = [];
- /// Multi-discipline clash coordination matrix associated with the assembly.
- public Clash.NwcClashMatrix? ClashMatrix { get; set; }
-
/// Diagnostics from contributing models plus assembly-level issues such as unresolved references.
public IReadOnlyList Diagnostics { get; internal set; } = [];
@@ -277,85 +274,6 @@ public static NwcAssembly LoadFromDirectory(
return Create(assemblyName, docs);
}
- ///
- /// Opens a federation manifest (.nwf.xml) and loads the .nwc/.nwd models it lists.
- /// Relative paths are resolved under the manifest folder; an absolute path is tried as written first
- /// and then by its trailing segments under the manifest folder. Backslashes in stored paths are read as
- /// directory separators on every platform. Only the model list is read: viewpoints, sets, appearance
- /// rules and clash tests of the manifest are not loaded.
- /// Missing and unsupported entries are recorded on
- /// and .
- ///
- /// The manifest is missing, or none of its models could be resolved.
- public static NwcAssembly OpenManifest(string manifestPath, NwcReaderOptions? options = null)
- => OpenManifest(manifestPath, options, null, default);
-
- ///
- /// Opens a federation manifest with cancellation and progress for each listed model.
- ///
- public static NwcAssembly OpenManifest(
- string manifestPath,
- NwcReaderOptions? options,
- IProgress? progress,
- CancellationToken cancellationToken)
- {
- ArgumentNullException.ThrowIfNull(manifestPath);
- if (!File.Exists(manifestPath))
- {
- throw new FileNotFoundException($"Manifest file not found: {manifestPath}", manifestPath);
- }
-
- var manifest = Clash.NwcNwfManifest.Open(manifestPath);
- var baseDir = Path.GetDirectoryName(Path.GetFullPath(manifestPath)) ?? ".";
- var loadedDocs = new List();
- var loadedPaths = new HashSet(OperatingSystem.IsWindows()
- ? StringComparer.OrdinalIgnoreCase
- : StringComparer.Ordinal);
- var unresolved = new List();
- var skipped = new List();
-
- int processed = 0;
- foreach (var modelPath in manifest.ModelPaths)
- {
- cancellationToken.ThrowIfCancellationRequested();
- progress?.Report(new NwcProgress("load-models", processed++, manifest.ModelPaths.Count));
- var xref = new NwcXRef(modelPath.Replace('\\', Path.DirectorySeparatorChar), "");
- if (!xref.TryResolve(baseDir, out string resolved))
- {
- unresolved.Add(xref);
- continue;
- }
-
- if (!resolved.EndsWith(".nwc", StringComparison.OrdinalIgnoreCase) &&
- !resolved.EndsWith(".nwd", StringComparison.OrdinalIgnoreCase))
- {
- skipped.Add(xref);
- continue;
- }
-
- if (loadedPaths.Add(Path.GetFullPath(resolved)))
- {
- loadedDocs.Add(NwcDocument.Open(resolved, options, null, cancellationToken));
- }
- }
-
- if (loadedDocs.Count == 0)
- {
- throw new FileNotFoundException(
- $"No .nwc or .nwd models listed in manifest '{manifestPath}' could be resolved.");
- }
-
- progress?.Report(new NwcProgress("load-models", manifest.ModelPaths.Count, manifest.ModelPaths.Count));
- string fileName = Path.GetFileNameWithoutExtension(manifestPath);
- string assemblyName = fileName.EndsWith(".nwf", StringComparison.OrdinalIgnoreCase)
- ? Path.GetFileNameWithoutExtension(fileName)
- : fileName;
- var assembly = Create(assemblyName, loadedDocs);
- assembly.UnresolvedXRefs = unresolved;
- assembly.SkippedXRefs = skipped;
- return assembly;
- }
-
///
/// Opens a Navisworks File (.nwf) assembly, automatically discovering and loading its external references.
///
@@ -462,47 +380,6 @@ public static Task OpenNwfAsync(
CancellationToken cancellationToken = default)
=> Task.Run(() => OpenNwf(nwfPath, options, progress, cancellationToken), cancellationToken);
- /// Creates a Navisworks Federated Project Manifest (NWF) representation of this assembly.
- public Clash.NwcNwfManifest ToNwfManifest()
- {
- var manifest = new Clash.NwcNwfManifest(Name);
- for (int i = 0; i < Models.Count; i++)
- {
- var p = Models[i].GetLoadedPath();
- if (string.IsNullOrEmpty(p))
- {
- p = Models[i].FileInfo.SourcePath;
- }
- if (!string.IsNullOrEmpty(p))
- {
- manifest.ModelPaths.Add(p);
- }
- }
- manifest.SavedViewpoints.AddRange(SavedViewpoints);
- manifest.Sets.AddRange(SelectionSets);
- foreach (var model in Models)
- {
- if (model.AppearanceProfiler is not null)
- {
- manifest.AppearanceProfiler.Rules.AddRange(model.AppearanceProfiler.Rules);
- }
- }
- manifest.ClashTests.AddRange(ClashTests);
- return manifest;
- }
-
- /// Saves the assembly coordination manifest as a Navisworks NWF coordination file (.nwf.xml).
- public void SaveNwf(string path)
- {
- var manifest = ToNwfManifest();
- var directory = Path.GetDirectoryName(Path.GetFullPath(path))!;
- for (var i = 0; i < manifest.ModelPaths.Count; i++)
- {
- manifest.ModelPaths[i] = Path.GetRelativePath(directory, manifest.ModelPaths[i]);
- }
- manifest.Save(path);
- }
-
///
/// Builds a single document that carries the assembly scene tree, meshes with their transforms,
/// viewpoints, GUIDs, the assembly selection sets and the assembly TimeLiner schedule.
diff --git a/src/NwcIO/NwcDocument.cs b/src/NwcIO/NwcDocument.cs
index b98f5f3..f5d4d61 100644
--- a/src/NwcIO/NwcDocument.cs
+++ b/src/NwcIO/NwcDocument.cs
@@ -89,15 +89,18 @@ private NwcDocument(
/// Navisworks Appearance Profiler color/transparency rules associated with the document.
public Model.Appearance.NwcAppearanceProfiler? AppearanceProfiler { get; set; }
- /// Configured Clash Detective tests and results for this document.
- public List ClashTests { get; } = [];
+ /// Applies an appearance profiler to colorize the document based on property rules.
+ /// The total number of scene nodes and meshes whose appearance was overridden.
+ public int ApplyAppearanceProfiler(Model.Appearance.NwcAppearanceProfiler profiler)
+ {
+ ArgumentNullException.ThrowIfNull(profiler);
+ AppearanceProfiler = profiler;
+ return profiler.Apply(this);
+ }
/// Reader diagnostics for data that was skipped or substituted.
public IReadOnlyList Diagnostics { get; internal set; } = [];
- /// Spatial grid system (axes and levels) associated with the document.
- public Model.Grids.NwcGridSystem? GridSystem { get; set; }
-
/// Gets the total 3D bounding box over all meshes in the document.
public BoundingBox3d BoundingBox => SpatialIndex.Bounds;
diff --git a/src/NwcIO/NwcDocumentBuilder.cs b/src/NwcIO/NwcDocumentBuilder.cs
index a89fb95..2339a29 100644
--- a/src/NwcIO/NwcDocumentBuilder.cs
+++ b/src/NwcIO/NwcDocumentBuilder.cs
@@ -5,7 +5,7 @@ namespace NwcIO;
///
/// A fluent builder for programmatically creating new instances.
///
-public sealed class NwcDocumentBuilder
+public sealed partial class NwcDocumentBuilder
{
private readonly NwcFileInfo _fileInfo = new();
private readonly List _meshes = [];
@@ -15,7 +15,6 @@ public sealed class NwcDocumentBuilder
private readonly List _propertyRecords = [];
private readonly List _materials = [];
private readonly List _selectionSets = [];
- private readonly List _clashTests = [];
private Model.TimeLiner.NwcTimeLinerSchedule? _timeLiner;
private Model.Appearance.NwcAppearanceProfiler? _appearanceProfiler;
private NwcNode? _rootNode;
@@ -151,16 +150,6 @@ public NwcDocumentBuilder AddAppearanceRule(Model.Appearance.NwcAppearanceRule r
return this;
}
- ///
- /// Adds a Clash Detective test to the document.
- ///
- public NwcDocumentBuilder AddClashTest(Model.Clash.NwcClashTest test)
- {
- ArgumentNullException.ThrowIfNull(test);
- _clashTests.Add(test);
- return this;
- }
-
///
/// Builds and returns the constructed .
///
@@ -178,7 +167,9 @@ public NwcDocument Build()
selectionSets: _selectionSets,
timeLiner: _timeLiner,
appearanceProfiler: _appearanceProfiler);
- doc.ClashTests.AddRange(_clashTests);
+ AddConfiguredClashTests(doc);
return doc;
}
+
+ partial void AddConfiguredClashTests(NwcDocument document);
}
diff --git a/src/NwcIO/NwcIO.csproj b/src/NwcIO/NwcIO.csproj
index 75f126f..47e026d 100644
--- a/src/NwcIO/NwcIO.csproj
+++ b/src/NwcIO/NwcIO.csproj
@@ -9,6 +9,14 @@
0.12.1
+
+ false
+
+
+
+
+
+
From 2ca7880c5224c5a679ddaad0d2692476e5e27b44 Mon Sep 17 00:00:00 2001
From: mahach666 <79989386+mahach666@users.noreply.github.com>
Date: Wed, 18 Nov 2026 04:50:22 +0300
Subject: [PATCH 2/3] Document the IOScene replacement previews
---
README.md | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index f76bfcb..66d1d7b 100644
--- a/README.md
+++ b/README.md
@@ -190,7 +190,10 @@ NwcIO reads and writes its own format. These extras are frozen: they receive bug
JSON export (`NwcDocument.SaveJson`, `nwcio model.nwc model.json`) is not frozen: it is core and grows with the reader.
-Viewing will move to [IOViewer](https://github.com/IOExtend/IOViewer) through the `NwcIO.Scene` adapter over the shared `IOScene` model. Coordination features such as clash, measure, diff, and BCF will move to a planned `IOCoord` package, and GLB export to a shared GLB writer in a planned `IOScene.Formats` package. `IOCoord` and `IOScene.Formats` are not published yet. The frozen features stay available and are removed no earlier than NwcIO 1.0, and only after a published replacement exists.
+For viewing through [IOViewer](https://github.com/IOExtend/IOViewer), use `NwcIO.Scene` in .NET or export the scene with
+`nwcio model.nwc --scene model.scene.json`. The [IOScene tools source previews](https://github.com/IOExtend/IOScene/blob/main/docs/tools.md)
+provide a shared GLB writer in `IOScene.Formats` and coordination queries and BCF export in `IOCoord`. The existing frozen
+features stay in the regular `NwcIO` package and are removed no earlier than NwcIO 1.0, and only after a published replacement exists.
## Build from source and tests
From 8a24e8d8d7fd97559687317fd0a7e26bffbb37d7 Mon Sep 17 00:00:00 2001
From: mahach666 <79989386+mahach666@users.noreply.github.com>
Date: Wed, 18 Nov 2026 04:52:52 +0300
Subject: [PATCH 3/3] Verify the scene adapter against the native engine
---
.github/workflows/ci.yml | 2 +-
CONTRIBUTING.md | 5 +++--
.../Compatibility/NwcSceneReader.Compatibility.cs | 14 ++++++++++++++
src/NwcIO.Scene/NwcIO.Scene.csproj | 8 ++++++++
src/NwcIO.Scene/NwcSceneReader.cs | 7 +++----
5 files changed, 29 insertions(+), 7 deletions(-)
create mode 100644 src/NwcIO.Scene/Compatibility/NwcSceneReader.Compatibility.cs
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7d428e5..c011740 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -32,7 +32,7 @@ jobs:
path: coverage/**/coverage.cobertura.xml
if-no-files-found: error
- run: dotnet pack NwcIO.slnx -c Release --no-build -o artifacts
- - run: dotnet build src/NwcIO/NwcIO.csproj -c Release -p:BuildNativeCoreOnly=true --artifacts-path native-core-check
+ - run: dotnet build src/NwcIO.Scene/NwcIO.Scene.csproj -c Release -p:BuildNativeCoreOnly=true --artifacts-path native-core-check
- uses: actions/upload-artifact@v7
with:
name: packages-${{ matrix.os }}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index d4c2b2b..6f43878 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -33,12 +33,13 @@ Keep new native-format operations with the reader or writer.
The CLI uses the public APIs of NwcIO and NwcIO.Scene. Command-specific
presentation, such as model labels in raycast output, belongs to the CLI.
-CI also compiles the native library with the compatibility sources excluded.
+CI also compiles the native library and its scene adapter with the compatibility
+sources excluded.
Use a separate artifact path for this compile check. It keeps the regular
build available for testing and produces no NuGet package.
```sh
-dotnet build src/NwcIO/NwcIO.csproj -c Release -p:BuildNativeCoreOnly=true --artifacts-path ./artifacts/native-core-check
+dotnet build src/NwcIO.Scene/NwcIO.Scene.csproj -c Release -p:BuildNativeCoreOnly=true --artifacts-path ./artifacts/native-core-check
```
## Test Fixtures
diff --git a/src/NwcIO.Scene/Compatibility/NwcSceneReader.Compatibility.cs b/src/NwcIO.Scene/Compatibility/NwcSceneReader.Compatibility.cs
new file mode 100644
index 0000000..ae7af01
--- /dev/null
+++ b/src/NwcIO.Scene/Compatibility/NwcSceneReader.Compatibility.cs
@@ -0,0 +1,14 @@
+using IOScene;
+
+namespace NwcIO.Scene;
+
+public static partial class NwcSceneReader
+{
+ static partial void ReportLegacyClashTests(NwcDocument document, List diagnostics)
+ {
+ if (document.ClashTests.Count > 0)
+ {
+ diagnostics.Add(new SceneDiagnostic(SceneSeverity.Warning, "clash-tests-skipped", "Clash tests are not converted."));
+ }
+ }
+}
diff --git a/src/NwcIO.Scene/NwcIO.Scene.csproj b/src/NwcIO.Scene/NwcIO.Scene.csproj
index 8a6f57b..04a4893 100644
--- a/src/NwcIO.Scene/NwcIO.Scene.csproj
+++ b/src/NwcIO.Scene/NwcIO.Scene.csproj
@@ -8,6 +8,14 @@
$(NoWarn);NU5104
+
+ false
+
+
+
+
+
+
diff --git a/src/NwcIO.Scene/NwcSceneReader.cs b/src/NwcIO.Scene/NwcSceneReader.cs
index b2a4c54..c45c9fb 100644
--- a/src/NwcIO.Scene/NwcSceneReader.cs
+++ b/src/NwcIO.Scene/NwcSceneReader.cs
@@ -524,10 +524,7 @@ private static NwcSceneResult ConvertInto(
diagnostics.Add(new SceneDiagnostic(SceneSeverity.Warning, "timeliner-skipped", "The TimeLiner schedule is not converted."));
}
- if (document.ClashTests.Count > 0)
- {
- diagnostics.Add(new SceneDiagnostic(SceneSeverity.Warning, "clash-tests-skipped", "Clash tests are not converted."));
- }
+ ReportLegacyClashTests(document, diagnostics);
if (propertyValuesSkipped > 0)
{
@@ -548,6 +545,8 @@ private static NwcSceneResult ConvertInto(
};
}
+ static partial void ReportLegacyClashTests(NwcDocument document, List diagnostics);
+
// OST_Grids (-2000220) in the element's own LcRevitData_Element tab.
private static bool IsGrid(NwcNode node) =>
node.PropertyTabs.Any(t => t.InternalName == "LcRevitData_Element"