From 8110241b69069df683d3b81959948820d05f924f Mon Sep 17 00:00:00 2001
From: sim <79989386+mahach666@users.noreply.github.com>
Date: Thu, 3 Dec 2026 11:14:15 +0300
Subject: [PATCH 1/2] Read IFC string properties and point geometry in
Navisworks models
---
CHANGELOG.md | 4 ++
docs/format-notes.md | 10 ++--
docs/public-api.md | 2 +-
.../Internal/Container/NwcStreamSerializer.cs | 5 ++
src/NwcIO/Internal/Json/JsonExporter.cs | 6 +++
.../Internal/Parsing/GeometryRecordParser.cs | 54 +++++++++++++------
src/NwcIO/Internal/Parsing/HierarchyParser.cs | 21 ++++++--
.../Internal/Parsing/ModelGraphReader.cs | 2 +
src/NwcIO/Model/NwcMesh.cs | 9 +++-
.../NwcIO.Tests/GeometryRecordParserTests.cs | 2 +-
tests/NwcIO.Tests/ModelGraphReaderTests.cs | 27 ++++++++++
tests/NwcIO.Tests/PartitionPropsTests.cs | 27 ++++++++++
12 files changed, 143 insertions(+), 26 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a06bbb9..347fc7b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,10 @@ All notable changes to the `NwcIO` library, the CLI and the `NwcIO.Scene` adapte
## [Unreleased]
+### Fixed
+
+- Read IFC string properties and class-96 point geometry in Navisworks model files (#291).
+
## [0.18.0] - 2026-11-23
### Added
diff --git a/docs/format-notes.md b/docs/format-notes.md
index b8b189d..72fe3b5 100644
--- a/docs/format-notes.md
+++ b/docs/format-notes.md
@@ -77,8 +77,9 @@ SEGMENT := [int32 0] ZSTREAM{k} ZTOC contiguous zlib streams from off
ZTOC := [int32 k] [k x int32 compressed length of ZSTREAM i] zero pad to 8 (length roundup8(4 + 4k))
HIERARCHY HEADER := [int32 k >= 1] [k x int32 n_i] n_i = number of roots in ZSTREAM i
ZSTREAM i := ROOT{n_i} zero pad to 8 ids from 100 per stream, no implicit root
-ROOT := a new object (never null, never a back-reference) of class 86, 79 or 66; nested objects are class 52
+ROOT := a new object (never null, never a back-reference) of class 86, 79, 66 or 70; nested objects are class 52
66 := [str name = null] [ptr 52 key, internal "LcRevitId"] [i32 flags = 0x01000000 or 0x00020000] PAD8 [i64 value in 1..2^31-1]
+70 := [str value] [ptr 52 key] [i32 flags]
LINK := the n-th null attribute slot of a hierarchy node, in byte order, takes the n-th root of ZSTREAM 0 ‖ ZSTREAM 1 ‖ ...
```
@@ -136,7 +137,7 @@ In Revit NWC caches this is a single zlib stream holding a tree in preorder. Eac
Each record is a strict grammar that ends exactly at its TOC length. `int` is a little-endian `int32`; every pad byte and unused packed bit is 0.
```text
-RECORD := [100][cls] V UVSLOT NSLOT CSLOT P SFIELD? pad8
+RECORD := [100][cls] V UVSLOT NSLOT CSLOT (P SFIELD? | [0] for points) pad8
V := [101][60][p1][p2][p2 x f32 xyz] VMAP? (npos = p2/3; VMAP iff p1 != npos)
UVSLOT := 0 | [id][61] UVBODY
NSLOT := 0 | [id][100][-p1][pal] PACKED(3*pal, B) NTOK? (NTOK iff pal != p1)
@@ -149,8 +150,8 @@ UVBODY := [p1][fc][fc x f32] TOKENS(p1, fc/2)? (raw; tokens iff fc/2 != p
```
- **Colour palette**: entries are `[A=0xFF][B][G][R]` (a little-endian `uint32` `0xRRGGBBAA`). Evidence: a level's line colour equals its type's colour parameter (a Revit colour int, red in the low byte) in 218 of 218 level lines that are not black; the 95 whose colour tells the orders apart all match this order. A line record can carry several colours, per vertex.
-- **Class**: `94` triangles, `95` lines. Class 94 always has a normal slot; class 95 never has a UV or normal slot. The colour slot is optional in both (`.nwd` files saved by Navisworks 2026 have triangle records with one and line records without one): a triangle record's colours are read for length and dropped, and a line record without colours falls back to its material colour. Object ids run 100, 101, then 102, 103 over the slots present.
-- **`p1` is the render-vertex count**, not the position count. `p2/3` positions are stored; `VMAP` maps each render vertex to a position and is the identity when absent. Quantised positions (negative `p1`) and point records (class 96) are not supported.
+- **Class**: `94` triangles, `95` lines, `96` points. Class 94 always has a normal slot; classes 95 and 96 never have a UV or normal slot. The colour slot is optional (`.nwd` files saved by Navisworks 2026 have triangle records with one and line records without one): a triangle record's colours are read for length and dropped, and a line record without colours falls back to its material colour. Object ids run 100, 101, then 102, 103 over the slots present.
+- **`p1` is the render-vertex count**, not the position count. `p2/3` positions are stored; `VMAP` maps each render vertex to a position and is the identity when absent. Quantised positions (negative `p1`) are not supported.
- **PACKED(count, w)**: bit `j` of the stream is bit `31 - j%32` of little-endian word `j/32`; value `k` occupies bits `k*w` to `k*w+w-1`, most significant first.
- **TOKENS(count, fresh)**: one byte code for every map. State: `out = []`, `next = 0`; read lead bytes until `count` values exist.
@@ -167,6 +168,7 @@ UVBODY := [p1][fc][fc x f32] TOKENS(p1, fc/2)? (raw; tokens iff fc/2 != p
- **Normals** (class 94): a palette entry is three two's-complement values of width `B`, divided by `2^(B-1)-1` and normalised; a zero vector means no normal. `B` is not stored in the record: it is the width under which every record of the file parses (16 for `.nwc`, 8 for `.nwd`). Render vertex `r` takes `palette[NIdx[r]]`, or an axis vector for an axis code (`D0` +X, `D1` -X, `D2` +Y, `D3` -Y, `D4` +Z, `D5` -Z).
- **Triangles** (class 94): corners are `0..p1-1` when `S = 0`, otherwise `TOKENS(S, p1)`. They are split by `L` into consecutive strips; in each strip, triangle `i` is `(c[i], c[i+1], c[i+2])` for even `i` and `(c[i+1], c[i], c[i+2])` for odd `i`. Parity restarts in every strip. The triangle count is the sum of `L-2`. Front faces are counter-clockwise.
- **Polylines** (class 95): render vertices `0..p1-1` are split by `L` into open polylines; the segment count is the sum of `L-1`. There is no implicit closing segment.
+- **Points** (class 96): each render vertex is one point. A zero int follows the attribute slots and precedes the pad to 8.
- **UVBODY**: the raw form stores interleaved `f32` U/V pairs. The quantised form stores `[U0 bits][V0 bits][U1 bits][V1 bits]…` using `PACKED`. The widths are `bu = w & 0xFF` and `bv = (w >> 8) & 0xFF`. A nonzero-width code `q` represents `min + q/(2^bits - 1) × (max - min)`; width zero takes that axis's minimum. Both widths may be zero for a constant pair. The token stream maps each of the `p1` render vertices to a stored pair, independently of the position map. U/V use the lower-left origin, as confirmed by converting a synthetic OBJ with asymmetric coordinates in Navisworks.
- **Writer records**: `NwcWriter` emits its own simplified record, `[id][94][0][60][p1][p2][p2 x f32 xyz]`, followed by the trailer `["NWCI"][indexCount][indexCount x i32][Id i32][nameLength][UTF-8 name][pad4]`. The fallback mesh parser (§2.5) restores the exact triangle indices, `Id` and `Name` from the trailer; records without it keep the rebuilt strip and the synthesized `Mesh_{index}` identity. The trailer is writer-specific: it is not part of the documented Navisworks grammar.
diff --git a/docs/public-api.md b/docs/public-api.md
index 79ebd23..ef1c3fc 100644
--- a/docs/public-api.md
+++ b/docs/public-api.md
@@ -20,7 +20,7 @@ The supported surface is the `NwcIO` and `NwcIO.Model.*` namespaces listed here
| `NwcNode` | Scene graph tree node representing layers, categories, composite elements, and geometry instances with optional transformations and properties. For Navisworks model files read through their DbCache directory (the strict path), `Meshes` lists every mesh placed on a leaf and `Mesh` the first, ids are depth-first preorder indices, `Transform` is null; `IsElement` marks Revit element nodes, `ElementGuid` is their export GUID from `LcOpGuidStore`, `IfcGlobalId` is the GlobalId the Revit IFC export gives the element: its valid `IFC_GUID` parameter, else its export GUID in the IFC base-64 form (the rule of `RvtIO.Scene`), and `Element` points every node inside an element (and the second node of a sibling pair that repeats one element) to its element node; properties include the tabs stored in `LcOaPartitionProps`; other files leave `Meshes` empty and `Mesh` null. |
| `NwcPropertyRecord` | Property record (`Class`, `Name`, `Value`, `ValueType`, `Tag`, `FirstInt`; typed `IntValue`, `DoubleValue`, `ReferenceId`, `ReferenceTag`, `ReferenceClass`). On node properties of the strict path, `Class` is the property tab name (category, for example `Element`), `Name` the property name and `FirstInt` the key object id. Records scanned from property streams (`NwcDocument.PropertyRecords`, and node properties of other files) keep their internal class names. `TabInternalName` and `InternalName` are the internal names of the tab and the key on strict-path node properties, null on scanned records. |
| `NwcPropertyTab` | One property tab of a strict-path node (`NwcNode.PropertyTabs`, in stored slot order): display `Name`, `InternalName`, `Properties`. A tab object shared by several nodes is one instance. |
-| `NwcMesh` | Triangle mesh with vertices, indices, `Normals` aligned with vertices, `LineIndices` for polylines, world-space transform, bounding box, and material. Model files hold one mesh per placed fragment; `Id` is the fragment index. Meshes of fragments that share a geometry record share their `Vertices`, `Indices`, `Normals`, `LineIndices` and `LineColors` arrays; do not mutate them. `GeometryIndex` (the geometry record; −1 outside model files) and `LineColors` (per vertex, line meshes of model files). |
+| `NwcMesh` | Geometry with vertices, triangle indices, `Normals` aligned with vertices, and `LineIndices` for polylines. For `IsPointSet` meshes, each vertex is a point, with optional `PointColors` and no triangle or line indices. JSON mesh summaries include `pointCount` for these meshes. Meshes also carry a world-space transform, bounding box, and material. Model files hold one mesh per placed fragment; `Id` is the fragment index. Meshes of fragments that share a geometry record share their `Vertices`, `Indices`, `Normals`, `LineIndices`, `LineColors` and `PointColors` arrays; do not mutate them. `GeometryIndex` (the geometry record; −1 outside model files) and `LineColors` (per vertex, line meshes of model files). |
| `NwcMaterial` | Colour and PBR material. On the strict path, `Name` comes from the nearest class-31 material on the mesh's leaf or an ancestor (`Default` when absent or empty), `Color` comes from the fragment's diffuse appearance with alpha `1 - transparency`, and `DiffuseTexture` comes from its Generic diffuse map. Each colour channel is rounded to a byte (halves away from zero). `Roughness` and `Metallic` keep their defaults. `NwcDocument.Materials` lists distinct name, RGBA and texture combinations in order of first use. With `BuildSceneTree = false`, appearances with a diffuse image still supply a material named `Default`. Elsewhere names come from material references in property records and the colour from a `revit_Color` record that follows the definition. A material without that record gets a neutral grey and `IsInferred = true`. Meshes without a material share one neutral `Default Material` per document with `IsInferred = true`. |
| `NwcTransform` | Parsed pose/transform records with quaternion rotation, uniform `Scale` (negative for a mirrored placement) and affine 4×4 matrix conversion. Model files hold one transform per fragment, with the same `Id` as its mesh. |
| `NwcFileInfo` | Source path, loader plugin, export timestamp from partition header, format version, text encoding, and chunk marker from section headers. |
diff --git a/src/NwcIO/Internal/Container/NwcStreamSerializer.cs b/src/NwcIO/Internal/Container/NwcStreamSerializer.cs
index 1b95194..9839006 100644
--- a/src/NwcIO/Internal/Container/NwcStreamSerializer.cs
+++ b/src/NwcIO/Internal/Container/NwcStreamSerializer.cs
@@ -114,6 +114,11 @@ private static void ValidateDocument(NwcDocument doc)
}
}
+ if (mesh.IsPointSet)
+ {
+ throw new ArgumentException($"Mesh {mesh.Id.ToString(CultureInfo.InvariantCulture)} holds point primitives, which the .nwc writer cannot store.", nameof(doc));
+ }
+
if (mesh.LineIndices.Count > 0)
{
throw new ArgumentException($"Mesh {mesh.Id.ToString(CultureInfo.InvariantCulture)} holds line segments, which the .nwc writer cannot store.", nameof(doc));
diff --git a/src/NwcIO/Internal/Json/JsonExporter.cs b/src/NwcIO/Internal/Json/JsonExporter.cs
index 61d65fa..4dbe6f8 100644
--- a/src/NwcIO/Internal/Json/JsonExporter.cs
+++ b/src/NwcIO/Internal/Json/JsonExporter.cs
@@ -171,6 +171,12 @@ private static async ValueTask WriteDocument(
writer.WriteString("name", mesh.Name);
writer.WriteNumber("vertexCount", mesh.Vertices.Count);
writer.WriteNumber("triangleCount", mesh.TriangleCount);
+
+ if (mesh.IsPointSet)
+ {
+ writer.WriteNumber("pointCount", mesh.Vertices.Count);
+ }
+
if (mesh.Material is not null)
{
writer.WriteString("material", mesh.Material.Name);
diff --git a/src/NwcIO/Internal/Parsing/GeometryRecordParser.cs b/src/NwcIO/Internal/Parsing/GeometryRecordParser.cs
index 2812071..bf35a94 100644
--- a/src/NwcIO/Internal/Parsing/GeometryRecordParser.cs
+++ b/src/NwcIO/Internal/Parsing/GeometryRecordParser.cs
@@ -4,10 +4,11 @@
namespace NwcIO.Internal.Parsing;
-/// A decoded geometry record: triangles (class 94) or lines (class 95).
+/// A decoded geometry record: triangles (class 94), lines (class 95) or points (class 96).
internal sealed class GeometryRecord
{
public required bool IsLines { get; init; }
+ public bool IsPoints { get; init; }
/// Render vertices: render vertex r sits at position VMap[r].
public required Vector3d[] Vertices { get; init; }
@@ -27,10 +28,13 @@ internal sealed class GeometryRecord
/// One colour per render vertex for lines; null for triangles.
public RgbaColor[]? LineColors { get; init; }
+ /// One colour per point when stored.
+ public RgbaColor[]? PointColors { get; init; }
+
/// Axis-aligned bounds of the stored positions.
public required BoundingBox3d Bounds { get; init; }
- public int PrimitiveCount => IsLines ? LineIndices.Length / 2 : Indices.Length / 3;
+ public int PrimitiveCount => IsPoints ? Vertices.Length : IsLines ? LineIndices.Length / 2 : Indices.Length / 3;
}
///
@@ -56,9 +60,9 @@ public static GeometryRecord Parse(ReadOnlySpan record, int normalBits)
Expect(record, ref pos, 100, "record id is not 100");
int at = pos;
int cls = ReadInt32(record, ref pos);
- if (cls is not (94 or 95))
+ if (cls is not (94 or 95 or 96))
{
- throw Fail("class is not 94 or 95", at);
+ throw Fail($"class {cls} is not 94, 95 or 96", at);
}
bool lines = cls == 95;
@@ -214,7 +218,7 @@ public static GeometryRecord Parse(ReadOnlySpan record, int normalBits)
at = pos;
id = ReadInt32(record, ref pos);
bool hasColour = id != 0;
- RgbaColor[]? lineColors = null;
+ RgbaColor[]? colors = null;
if (hasColour)
{
ExpectId(id, ref nextId, at);
@@ -240,18 +244,33 @@ public static GeometryRecord Parse(ReadOnlySpan record, int normalBits)
palette[k] = new RgbaColor(record[pos + 3] / 255f, record[pos + 2] / 255f, record[pos + 1] / 255f, record[pos] / 255f);
}
- lineColors = cpal == p1
+ colors = cpal == p1
? palette
: Array.ConvertAll(Tokens(record, ref pos, p1, cpal, false), k => palette[k]);
}
- // The colour slot is optional in both classes (seen in .nwd files saved by Navisworks 2026): triangles may carry one, which is
- // read for length and dropped, and lines may come without one, so their mesh falls back to its material colour.
- if (lines ? hasUv || normals is not null : normals is null)
+ if (cls == 94 ? normals is null : hasUv || normals is not null)
{
throw Fail("slot set does not match the class", pos);
}
+ if (cls == 96)
+ {
+ Expect(record, ref pos, 0, "point record terminator is not zero");
+ CheckEnd(record, ref pos);
+ return new GeometryRecord
+ {
+ IsLines = false,
+ IsPoints = true,
+ Vertices = vertices,
+ Indices = [],
+ LineIndices = [],
+ Normals = null,
+ PointColors = colors,
+ Bounds = bounds,
+ };
+ }
+
at = pos;
int count = ReadInt32(record, ref pos);
if (count <= 0)
@@ -316,11 +335,7 @@ public static GeometryRecord Parse(ReadOnlySpan record, int normalBits)
throw Fail("line index count is above the array limit", at);
}
- Pad(record, ref pos, 8);
- if (pos != record.Length)
- {
- throw Fail("record does not end at its TOC length", pos);
- }
+ CheckEnd(record, ref pos);
int[] indices = [], lineIndices = [];
int start = 0;
@@ -366,11 +381,20 @@ public static GeometryRecord Parse(ReadOnlySpan record, int normalBits)
LineIndices = lineIndices,
Normals = normals,
TexCoords = texCoords,
- LineColors = lines ? lineColors : null,
+ LineColors = lines ? colors : null,
Bounds = bounds,
};
}
+ private static void CheckEnd(ReadOnlySpan record, ref int pos)
+ {
+ Pad(record, ref pos, 8);
+ if (pos != record.Length)
+ {
+ throw Fail("record does not end at its TOC length", pos);
+ }
+ }
+
private static Vector2 ReadUv(ReadOnlySpan data, int offset)
{
var uv = new Vector2(BinaryPrimitives.ReadSingleLittleEndian(data[offset..]),
diff --git a/src/NwcIO/Internal/Parsing/HierarchyParser.cs b/src/NwcIO/Internal/Parsing/HierarchyParser.cs
index d712c0f..894a12e 100644
--- a/src/NwcIO/Internal/Parsing/HierarchyParser.cs
+++ b/src/NwcIO/Internal/Parsing/HierarchyParser.cs
@@ -33,7 +33,7 @@ internal static class HierarchyParser
private static ReadOnlySpan ExtraClasses => [185];
- private static ReadOnlySpan PartitionRootClasses => [86, 79, 66];
+ private static ReadOnlySpan PartitionRootClasses => [86, 79, 66, 70];
private static ReadOnlySpan KnownClasses => [53, 22, 32, 52, 86, 31, 40, 41, 39, 79, 200, 185];
@@ -307,6 +307,7 @@ public Parser(LcObjectReader reader, int guidCount, Func?>
200 => ReadExtra(),
185 => ReadMaterialJson(_reader),
66 => ReadElementId(),
+ 70 => ReadStringProperty(),
_ => throw new InvalidOperationException($"class {classId} has no body reader"),
};
@@ -524,6 +525,20 @@ private NwcPropertyTab ReadElementId()
throw _reader.Fail($"class-66 value {value} is outside 1..{int.MaxValue}");
}
+ return SingleProperty(key, 2, value.ToString(CultureInfo.InvariantCulture));
+ }
+
+ // Class 70 stores a string value in the name field, followed by its key and flags.
+ private NwcPropertyTab ReadStringProperty()
+ {
+ string? value = _reader.ReadString();
+ var key = ReadUsername();
+ _reader.ReadInt32();
+ return SingleProperty(key, 4, value);
+ }
+
+ private static NwcPropertyTab SingleProperty(Username key, int valueType, string? value)
+ {
string name = key.Display ?? "";
var record = new NwcPropertyRecord
{
@@ -531,8 +546,8 @@ private NwcPropertyTab ReadElementId()
Tag = 52,
Name = name,
Class = name,
- ValueType = 2,
- Value = value.ToString(CultureInfo.InvariantCulture),
+ ValueType = valueType,
+ Value = value,
TabInternalName = key.Internal,
InternalName = key.Internal,
};
diff --git a/src/NwcIO/Internal/Parsing/ModelGraphReader.cs b/src/NwcIO/Internal/Parsing/ModelGraphReader.cs
index a0ff703..8fe5503 100644
--- a/src/NwcIO/Internal/Parsing/ModelGraphReader.cs
+++ b/src/NwcIO/Internal/Parsing/ModelGraphReader.cs
@@ -192,6 +192,8 @@ public static async ValueTask ReadAsync(ModelSegments segments, NwcR
TexCoords = record.TexCoords,
LineIndices = record.LineIndices,
LineColors = record.LineColors,
+ IsPointSet = record.IsPoints,
+ PointColors = record.PointColors,
GeometryIndex = fragment.Record - 1,
BoundingBox = record.Bounds,
Transform = transform,
diff --git a/src/NwcIO/Model/NwcMesh.cs b/src/NwcIO/Model/NwcMesh.cs
index adce588..5cf92f8 100644
--- a/src/NwcIO/Model/NwcMesh.cs
+++ b/src/NwcIO/Model/NwcMesh.cs
@@ -3,8 +3,7 @@
namespace NwcIO.Model;
///
-/// A 3D polygon mesh extracted from Navisworks geometry streams,
-/// composed of 3D vertices, triangle indices, and local/world bounding boxes.
+/// Triangle, polyline or point geometry extracted from Navisworks geometry streams.
///
public sealed class NwcMesh
{
@@ -42,6 +41,12 @@ public sealed class NwcMesh
///
public IReadOnlyList? LineColors { get; init; }
+ /// Whether each vertex is a point primitive with no triangle or line indices.
+ public bool IsPointSet { get; init; }
+
+ /// One colour per point in , when stored.
+ public IReadOnlyList? PointColors { get; init; }
+
///
/// 0-based index of the geometry record this mesh was read from; -1 for meshes not read from a model file.
///
diff --git a/tests/NwcIO.Tests/GeometryRecordParserTests.cs b/tests/NwcIO.Tests/GeometryRecordParserTests.cs
index 079a603..c248a12 100644
--- a/tests/NwcIO.Tests/GeometryRecordParserTests.cs
+++ b/tests/NwcIO.Tests/GeometryRecordParserTests.cs
@@ -244,7 +244,7 @@ public void Parse_R5EightBitPalette_DecodesDiagonalNormal()
[InlineData("R1", 92, "C0", "lead byte is undefined")] // undefined NTOK lead
[InlineData("R1", 112, "01000040", "unused packed bit is set")] // unused packed bit
[InlineData("R1", 76, "67000000", "slot id is out of order")] // N id 103: id order
- [InlineData("R1", 4, "60000000", "class is not 94 or 95")] // class 96
+ [InlineData("R1", 4, "61000000", "class 97 is not 94, 95 or 96")] // unknown class 97
[InlineData("R1", -1, "0000000000000000", "record does not end at its TOC length")] // -1 = append: end != TOC length
[InlineData("R2", 122, "01", "pad byte is not zero")] // non-zero pad4
[InlineData("R2", 84, "D5", "lead byte is undefined")] // axis code outside N
diff --git a/tests/NwcIO.Tests/ModelGraphReaderTests.cs b/tests/NwcIO.Tests/ModelGraphReaderTests.cs
index 4d5ec95..ddd90ed 100644
--- a/tests/NwcIO.Tests/ModelGraphReaderTests.cs
+++ b/tests/NwcIO.Tests/ModelGraphReaderTests.cs
@@ -1,5 +1,6 @@
using System.Buffers.Binary;
using System.Text;
+using System.Text.Json;
using NwcIO.Internal.Container;
using NwcIO.Model;
using Xunit;
@@ -32,6 +33,32 @@ public void Open_F1File_LinksFragmentsToLeavesAndPoses()
Assert.Equal(3, doc.DbCache!.Entries.Count);
}
+ [Theory]
+ [InlineData(true)]
+ [InlineData(false)]
+ public void Open_PointRecord_KeepsPointsAndPlacement(bool tree)
+ {
+ var pointRecord = new LcGraphWriter().Int(100).Int(96).Int(101).Int(60).Int(2).Int(6)
+ .Float(0).Float(0).Float(0).Float(1).Float(2).Float(3).Int(0).Int(0).Int(0).Int(0).ToArray();
+ byte[] fragments = SyntheticFragments.Build(new Frag(2, new(10, 0, 0), 1, 2, 2, Rec: 1, MaxY: 2, MaxZ: 3));
+ byte[] file = SyntheticNwcFile.Build(FormatVectors.H1, fragments, [pointRecord], [pointRecord.Length]);
+
+ var doc = NwcDocument.Open(new MemoryStream(file), new NwcReaderOptions { BuildSceneTree = tree });
+
+ var mesh = Assert.Single(doc.Meshes);
+ Assert.True(mesh.IsPointSet);
+ Assert.Empty(mesh.Indices);
+ Assert.Empty(mesh.LineIndices);
+ Assert.Equal([new Vector3d(10, 0, 0), new(11, 2, 3)], mesh.GetWorldVertices());
+ Assert.Equal(tree, mesh.Node is not null);
+ using var json = JsonDocument.Parse(doc.ToJson(new NwcJsonExportOptions { IncludeMeshes = true }));
+ Assert.Equal(2, json.RootElement.GetProperty("meshes")[0].GetProperty("pointCount").GetInt32());
+
+ using var output = new MemoryStream();
+ Assert.Contains("holds point primitives", Assert.Throws(() => doc.Save(output)).Message);
+ Assert.Equal(0, output.Length);
+ }
+
[Fact]
public void Open_TranslationOnlyPose_PlacesMeshAtTheTranslation()
{
diff --git a/tests/NwcIO.Tests/PartitionPropsTests.cs b/tests/NwcIO.Tests/PartitionPropsTests.cs
index 0ebeafc..cba7012 100644
--- a/tests/NwcIO.Tests/PartitionPropsTests.cs
+++ b/tests/NwcIO.Tests/PartitionPropsTests.cs
@@ -44,6 +44,7 @@ public void Read_PropertiesOff_StillChecksTheRoots()
[InlineData("noSegment", "LcOpNwdLogicalHierarchy at byte ", ": the header names 1 LcOaPartitionProps roots, but the file has no LcOaPartitionProps segment")]
[InlineData("streamCount", "LcOaPartitionProps: 2 root streams, but the hierarchy header names 1", "")]
[InlineData("rootClass52", "LcOaPartitionProps stream 0 at byte ", ": class 52, which this slot does not allow")]
+ [InlineData("stringKeyNull", "LcOaPartitionProps stream 0 at byte ", ": null pointer in a slot that needs an object")]
[InlineData("rootNull", "LcOaPartitionProps stream 0 at byte ", ": null pointer in a slot that needs an object")]
[InlineData("name66", "LcOaPartitionProps stream 0 at byte ", ": class-66 name is not null")]
[InlineData("flags66", "LcOaPartitionProps stream 0 at byte ", ": class-66 flags 00000001 are not 01000000 or 00020000")]
@@ -134,6 +135,27 @@ public void Open_Class66Flags_KeepTheElementId(int flags)
Assert.Equal("1001", property.Value);
}
+ [Fact]
+ public void Open_StringPropertyRoot_KeepsItsValueAndFollowingRoot()
+ {
+ const string value = "0GS8QqTlP7bh1kkovqD1OQ";
+ var props = P(w =>
+ {
+ w.New(70);
+ w.Str(value);
+ HierarchyParserTests.Username(w, "IFC ID", "LcATFIFCId");
+ w.Int(0x01000000);
+ Id66(w);
+ });
+ byte[] file = SyntheticNwcFile.Build(H([2], 2), null, [], [], partitionProps: [props]);
+
+ var leaf = NwcDocument.Open(new MemoryStream(file)).RootNode!.Children[0].Children[0];
+ Assert.Equal(["LcATFIFCId", "LcRevitId"], leaf.PropertyTabs.Select(tab => tab.InternalName));
+ var property = Assert.Single(leaf.PropertyTabs[0].Properties);
+ Assert.Equal(("IFC ID", "LcATFIFCId", 4, value),
+ (property.Name, property.InternalName, property.ValueType, property.Value));
+ }
+
[Theory]
[InlineData(0, 3, "LcOaPartitionProps: the table of contents names 3 streams, not 2")]
[InlineData(4, 999, "LcOaPartitionProps: the table of contents gives stream 0 999 bytes, not ")]
@@ -276,6 +298,11 @@ private static void Id66(LcGraphWriter p, string? name = null, int flags = 0x010
"noSegment" => HierarchyParser.Read(H([1], 1), "Model", true, null, null),
"streamCount" => Read(H([1], 1), [OneTab, P(_ => { })]),
"rootClass52" => Read(H([1], 1), [P(p => HierarchyParserTests.Username(p, "K", "lcK"))]),
+ "stringKeyNull" => Read(H([1], 1), [P(p =>
+ {
+ p.New(70);
+ p.Str("Text").Null().Int(0x01000000);
+ })]),
"rootNull" => Read(H([1], 1), [P(p => p.Null())]),
"name66" => Read(H([1], 1), [P(p => Id66(p, name: "x"))]),
"flags66" => Read(H([1], 1), [P(p => Id66(p, flags: 1))]),
From 7f0ff4d495e33dcded1392470cae560beedf179e Mon Sep 17 00:00:00 2001
From: sim <79989386+mahach666@users.noreply.github.com>
Date: Thu, 3 Dec 2026 13:24:09 +0300
Subject: [PATCH 2/2] Preserve class-96 points in IOScene exports
---
CHANGELOG.md | 2 +-
docs/scene.md | 4 ++--
src/NwcIO.Scene/NwcSceneReader.Geometry.cs | 12 ++++++++++--
tests/NwcIO.Scene.Tests/NwcSceneReaderTests.cs | 15 +++++++++++++++
tests/NwcIO.Tests/Fixtures/SyntheticNwcFile.cs | 8 ++++++++
tests/NwcIO.Tests/ModelGraphReaderTests.cs | 5 +----
6 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 347fc7b..a67f7a6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,7 +6,7 @@ All notable changes to the `NwcIO` library, the CLI and the `NwcIO.Scene` adapte
### Fixed
-- Read IFC string properties and class-96 point geometry in Navisworks model files (#291).
+- Read IFC string properties and class-96 point geometry in Navisworks model files. The scene adapter preserves point geometry (#291).
## [0.18.0] - 2026-11-23
diff --git a/docs/scene.md b/docs/scene.md
index 25c539c..e8de8b6 100644
--- a/docs/scene.md
+++ b/docs/scene.md
@@ -44,7 +44,7 @@ The scene has one model per input document. Geometry and instance positions are
| Levels | Revit files only. A depth-1 node whose `LcRevitId` tab holds the element id of a level (an `OST_Levels` reference tab) becomes a `SceneLevel` named like the node, and the node and all its descendants carry its `LevelId`. `Elevation` is written in metres from the level's `LcRevitData_Parameter` length property (`lcldrevit_parameter_-1007102`); it is null when that value is absent, not a length, not finite, or the unit is unknown. |
| Property sets | One `ScenePropertySet` per property tab object, listed once for every element that refers to the tab (also when one element refers to it twice). A tab whose properties are all left out has no set. |
| Keys | Set key `nwc:` for the tabs `LcRevitData_Element`, `LcRevitData_Type`, `LcRevitMaterialProperties` and `LcRevitId`; property key `.` for the Revit element properties (category, category id, family, element id, name, type, `LcRevitId`) and for the names `lcldrevit_parameter_-` and `revit_`, except `revit_mat_cust_prop_*`. Other tabs and properties have no key. This derivation does not change; a golden test pins it. |
-| Geometry, instances | Shared geometry is written once per geometry record and instanced by each mesh with its transform (translation in metres). Triangles carry the stored normals, with a zero normal replaced by the area-weighted average of its triangles. Line meshes become `Lines` geometries (see [Limits](#limits)). |
+| Geometry, instances | Shared geometry is written once per geometry record and instanced by each mesh with its transform (translation in metres). Triangles carry the stored normals, with a zero normal replaced by the area-weighted average of its triangles. Line meshes become `Lines` geometries (see [Limits](#limits)). Point sets become unindexed `Points` geometries and use the placement's material colour. |
| Materials | Decoded from the file on the strict path: name, colour and alpha, one `SceneMaterial` per distinct name and colour, in order of first use. `Roughness` and `Metalness` keep IOScene's defaults. |
| Grids | A Revit grid (category `OST_Grids`) with exactly one single-segment line mesh that is horizontal within 1e-6 m becomes a line of one grid system named `Grids`, with `Elevation` = the start Z. Other grids stay elements. |
| Viewpoints | Saved viewpoints become `SceneViewpoint`s with camera position, target and up in metres, `FieldOfView` in radians, near/far distances in metres and perspective or orthographic projection. Views whose camera is not finite or whose document unit is unknown are left out with `viewpoints-skipped`. |
@@ -72,7 +72,7 @@ A property with no text, a non-finite number, numeric text that does not parse,
| Code | Severity | Meaning |
| --- | --- | --- |
| `no-source-id` | Info | Leaf nodes outside any Revit element have no `SourceId` (one aggregated entry with the count). |
-| `empty-mesh` | Info | A mesh has no triangles and no line segments; the entry names the element's GUID. |
+| `empty-mesh` | Info | A mesh has no triangles, line segments or points. The entry includes the element's GUID when available. |
| `unit-unknown` | Warning | The length unit is unknown (the file does not name it and `LengthUnit` is not set, or `LengthUnit` is `Unknown`): geometry, grid lines and length, area, volume and angle values are left out. |
| `line-colour-mixed` | Warning | Per geometry record: line segments join vertices of different colours and are drawn with the material colour. |
| `line-colours-capped` | Warning | Per geometry record: the record has more than 64 line colours; segments of the further colours are drawn with the material colour. |
diff --git a/src/NwcIO.Scene/NwcSceneReader.Geometry.cs b/src/NwcIO.Scene/NwcSceneReader.Geometry.cs
index 8a5dd37..d5e39a9 100644
--- a/src/NwcIO.Scene/NwcSceneReader.Geometry.cs
+++ b/src/NwcIO.Scene/NwcSceneReader.Geometry.cs
@@ -54,7 +54,7 @@ private static HashSet AddGeometry(NwcDocument document, SceneDocument
if (groups.Count == 0)
{
diagnostics.Add(new SceneDiagnostic(SceneSeverity.Info, "empty-mesh",
- $"Mesh {mesh.Id} has no triangles and no line segments; it has no geometry in the scene.", node.Element?.ElementGuid?.ToString("D")));
+ $"Mesh {mesh.Id} has no triangles, line segments or points; it has no geometry in the scene.", node.Element?.ElementGuid?.ToString("D")));
continue;
}
@@ -96,11 +96,19 @@ private static HashSet AddGeometry(NwcDocument document, SceneDocument
return placed;
}
- // The geometries of one geometry key with the colour of their instances: the triangles, then one line geometry per segment colour.
+ // One point geometry for a point set. Other meshes get their triangles, then one line geometry per segment colour.
private static List<(int Id, RgbaColor? Color)> AddGeometries(SceneDocument scene, NwcMesh mesh, object key, double metresPerUnit, List diagnostics)
{
var result = new List<(int Id, RgbaColor? Color)>();
Vector3d[] vertices = [.. mesh.Vertices.Select(v => new Vector3d(v.X * metresPerUnit, v.Y * metresPerUnit, v.Z * metresPerUnit))];
+ if (mesh.IsPointSet && vertices.Length > 0)
+ {
+ int id = scene.Geometries.Count + 1;
+ scene.Geometries.Add(new SceneGeometry { Id = id, Topology = SceneTopology.Points, Vertices = vertices });
+ result.Add((id, null));
+ return result;
+ }
+
if (mesh.Indices.Count > 0)
{
int id = scene.Geometries.Count + 1;
diff --git a/tests/NwcIO.Scene.Tests/NwcSceneReaderTests.cs b/tests/NwcIO.Scene.Tests/NwcSceneReaderTests.cs
index 5aec926..5753b2d 100644
--- a/tests/NwcIO.Scene.Tests/NwcSceneReaderTests.cs
+++ b/tests/NwcIO.Scene.Tests/NwcSceneReaderTests.cs
@@ -399,6 +399,21 @@ public void Read_RotatedInstance_KeepsTheRowVectorAxes()
Assert.Null(result.Document.Geometries[0].Normals); // no stored normals
}
+ [Fact]
+ public void Read_Class96Points_KeepsWorldPositions()
+ {
+ var result = Scene(SyntheticNwcFile.PointSet(), new() { ModelKey = "points", LengthUnit = NwcLengthUnit.Meters });
+
+ Assert.DoesNotContain(result.Diagnostics, d => d.Code == "empty-mesh");
+ var geometry = Assert.Single(result.Document.Geometries);
+ Assert.Equal(SceneTopology.Points, geometry.Topology);
+ Assert.Empty(geometry.Indices);
+ var instance = Assert.Single(result.Document.Instances);
+ Assert.Equal(geometry.Id, instance.GeometryId);
+ var transform = Assert.IsType(instance.Transform);
+ Assert.Equal([new Vector3d(10, 0, 0), new(11, 2, 3)], geometry.Vertices.Select(transform.Apply));
+ }
+
[Fact]
public void Read_EmptyMesh_HasNoGeometryAndIsReported()
{
diff --git a/tests/NwcIO.Tests/Fixtures/SyntheticNwcFile.cs b/tests/NwcIO.Tests/Fixtures/SyntheticNwcFile.cs
index 19d5679..c33bca0 100644
--- a/tests/NwcIO.Tests/Fixtures/SyntheticNwcFile.cs
+++ b/tests/NwcIO.Tests/Fixtures/SyntheticNwcFile.cs
@@ -137,6 +137,14 @@ void PropsSegment()
return [.. file];
}
+ public static byte[] PointSet()
+ {
+ var pointRecord = new LcGraphWriter().Int(100).Int(96).Int(101).Int(60).Int(2).Int(6)
+ .Float(0).Float(0).Float(0).Float(1).Float(2).Float(3).Int(0).Int(0).Int(0).Int(0).ToArray();
+ byte[] fragments = SyntheticFragments.Build(new Frag(2, new(10, 0, 0), 1, 2, 2, Rec: 1, MaxY: 2, MaxZ: 3));
+ return Build(FormatVectors.H1, fragments, [pointRecord], [pointRecord.Length]);
+ }
+
private static byte[] Zlib(byte[] data)
{
using var output = new MemoryStream();
diff --git a/tests/NwcIO.Tests/ModelGraphReaderTests.cs b/tests/NwcIO.Tests/ModelGraphReaderTests.cs
index ddd90ed..9a4f715 100644
--- a/tests/NwcIO.Tests/ModelGraphReaderTests.cs
+++ b/tests/NwcIO.Tests/ModelGraphReaderTests.cs
@@ -38,10 +38,7 @@ public void Open_F1File_LinksFragmentsToLeavesAndPoses()
[InlineData(false)]
public void Open_PointRecord_KeepsPointsAndPlacement(bool tree)
{
- var pointRecord = new LcGraphWriter().Int(100).Int(96).Int(101).Int(60).Int(2).Int(6)
- .Float(0).Float(0).Float(0).Float(1).Float(2).Float(3).Int(0).Int(0).Int(0).Int(0).ToArray();
- byte[] fragments = SyntheticFragments.Build(new Frag(2, new(10, 0, 0), 1, 2, 2, Rec: 1, MaxY: 2, MaxZ: 3));
- byte[] file = SyntheticNwcFile.Build(FormatVectors.H1, fragments, [pointRecord], [pointRecord.Length]);
+ byte[] file = SyntheticNwcFile.PointSet();
var doc = NwcDocument.Open(new MemoryStream(file), new NwcReaderOptions { BuildSceneTree = tree });