Repository navigation
Conversation
ResolveSelection returned every mesh of the document when the named sets resolved to nothing, so a misspelled set name, a set without meshes, or a set present in only one model of an assembly ran against the whole model without notice. The set branch now returns its matches even when they are empty, like the node id and filter branches, and Run throws an ArgumentException naming a set that none of the models contains. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mahach666
left a comment
There was a problem hiding this comment.
Changes requested: the intended fix is useful, but the inline comment below describes a regression reproduced against the reviewed head and the unchanged base. Please address it and add the indicated regression test before merging.
Finding: Validate set names only when that selection branch is active.
| { | ||
| foreach (var selection in new[] { test.SelectionA, test.SelectionB }) | ||
| { | ||
| foreach (string name in selection.SetNames) |
There was a problem hiding this comment.
[P2] Validate set names only when that selection branch is active
ResolveSelection gives ExplicitNodeIds precedence over FilterCondition and SetNames, but this new validation checks every set name unconditionally.
Reproduction: set SelectionA.ExplicitNodeIds = [1] (via Add/AddRange) and leave SelectionA.SetNames = ["unused missing set"]. With two overlapping meshes, the current main/base completes and returns one clash because the set-name branch is unused; this PR throws ArgumentException before resolving the explicit IDs. The same problem applies when FilterCondition overrides set names.
Please validate SetNames only when neither explicit IDs nor a filter condition determines the selection, and add a regression test for the existing precedence.
Fixes #52
ResolveSelectionreturned every mesh of the document when the named sets resolved to no meshes. A misspelled set name, a set whose nodes have no meshes, or, in an assembly, a set that exists in only one model all ran against the whole model without notice.Following the issue's suggestions:
SetNamesbranch always returns its matches, even when there are none, like theExplicitNodeIdsandFilterConditionbranches. A model of an assembly that lacks the set adds no meshes, and onlyNwcClashSelection.All()selects every mesh.NwcClashDetector.Runoverloads throw anArgumentExceptionthat names the test and the set when the set is in none of the models (the document, or every model of the assembly), before resolving anything. A set that exists in only some models of an assembly doesn't throw. The XML docs of both overloads mention the exception.NwcDocument.RunClashDetectionandNwcAssembly.RunClashDetectiongo throughRun, so they throw the same way. The CLI doesn't build set selections, so it isn't affected.Tests (
ClashDetectiveTests), each on documents whose meshes clash:SetSelection_UnknownSetName_ThrowsSetSelection_SetWithoutMeshes_SelectsNothing: a set of a node id with no mesh gives no clashes.SetSelection_SetInOneModelOnly_SelectsNothingFromTheOthers: the set is only in the first model of an assembly, and the second model adds nothing.SetSelection_SetMissingFromEveryModel_ThrowsAll four fail without the change.
dotnet build NwcIO.slnxsucceeds, andNwcIO.Testspasses locally: 243 passed, and 2 skipped because they need private Navisworks files (.NET 10.0.400 on Windows, withglobal.jsonpinned down to it temporarily; not committed).🤖 Generated with Claude Code