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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to the `NwcIO` library, the CLI and the `NwcIO.Scene` adapte

## [Unreleased]

### Fixed

- `NwcAssembly.ToDocument()` preserves explicit node visibility when copying the assembly tree.

## [0.17.0] - 2026-11-20

### Added
Expand Down
13 changes: 10 additions & 3 deletions src/NwcIO/Model/NwcAssembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ public static Task<NwcAssembly> OpenNwfAsync(
=> OpenNwfCore(nwfPath, options, progress, asynchronous: true, cancellationToken).AsTask();

/// <summary>
/// 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.
/// Builds a single document that carries the assembly scene tree and its explicit visibility flags,
/// meshes with their transforms, viewpoints, GUIDs, the assembly selection sets and the assembly TimeLiner schedule.
/// The file info is neutral and does not claim a Revit origin.
/// </summary>
/// <remarks>
Expand All @@ -432,7 +432,14 @@ public NwcDocument ToDocument()
int nextId = 0;
NwcNode Renumber(NwcNode source, NwcNode? parent)
{
var copy = new NwcNode { Id = nextId++, Name = source.Name, Class = source.Class, Parent = parent };
var copy = new NwcNode
{
Id = nextId++,
Name = source.Name,
Class = source.Class,
IsHidden = source.IsHidden,
Parent = parent,
};
copy.Properties.AddRange(source.Properties);
foreach (var child in source.Children)
{
Expand Down
19 changes: 19 additions & 0 deletions tests/NwcIO.Tests/AssemblyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,25 @@ public void ToDocument_NumbersTreeUniquelyLeavesAssemblyUntouchedAndSkipsModelSe
Assert.Null(document.TimeLiner);
}

[Fact]
public void ToDocument_PreservesExplicitNodeVisibility()
{
var source = CreateTreeModel("Model.ifc", 0, "Grid");
var sourceRoot = source.RootNode!;
sourceRoot.IsHidden = true;
var sourceChild = Assert.Single(sourceRoot.Children);
var assembly = NwcAssembly.Create("Fed", source);

var model = Assert.Single(assembly.ToDocument().RootNode!.Children);
var child = Assert.Single(model.Children);

Assert.True(model.IsHidden);
Assert.False(child.IsHidden);
Assert.NotSame(sourceRoot, model);
Assert.NotSame(sourceChild, child);
Assert.Same(model, child.Parent);
}

private static NwcDocument CreateComponentModel(string sourcePath, int meshId, double offsetX)
{
return new NwcDocumentBuilder().SetFileInfo(sourcePath)
Expand Down
Loading