|
![]() |
Namespace: Autodesk.Navisworks.Api
Assembly: Autodesk.Navisworks.Api (in Autodesk.Navisworks.Api.dll)
Syntax
Remarks
Selection sets are the equivalent of the Sets window in Navisworks GUI and allow selections of ModelItems to be grouped.
This can be an explicit collection of ModelItems in the Document or a dynamic result of a specific Search.
SelectionSets can be accessed through the ActiveDocument.SelectionSets property which is the main entry point to the structure.
For more information on this class see 'Selection Sets' in the 'Developer guide'.
Examples

using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Windows.Forms; using System.Text; using Autodesk.Navisworks.Api.Controls; static public string WriteSelectionSetContent(SavedItem item, string label, string lineText) { //set the output string output = lineText + "+ " + label + "\n"; //See if this SavedItem is a GroupItem if (item.IsGroup) { //Indent the lines below this item lineText += " "; //iterate the children and output foreach (SavedItem childItem in ((GroupItem)item).Children) { output += WriteSelectionSetContent(childItem, childItem.DisplayName, lineText); } } //return the node information return output; } /// <summary> /// Outputs to a message box the structure of the selection sets /// </summary> static public void ListSelectionSets() { //build output string for display string output = WriteSelectionSetContent( Autodesk.Navisworks.Api.Application.ActiveDocument.SelectionSets.RootItem, Autodesk.Navisworks.Api.Application.ActiveDocument.Title, ""); //output in a message box MessageBox.Show(output); }

using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Windows.Forms; using System.Text; using Autodesk.Navisworks.Api.Controls; static public void TestSavedItemReference() { //first check we have some data to test this with if (Autodesk.Navisworks.Api.Application.ActiveDocument.SelectionSets.RootItem.Children.Count > 0) { //get the first child item SavedItem item = Autodesk.Navisworks.Api.Application.ActiveDocument.SelectionSets.RootItem.Children[0]; //create the SavedItemReference SavedItemReference reference = Autodesk.Navisworks.Api.Application.ActiveDocument.SelectionSets.CreateReference(item); //check the resolved reference if (Autodesk.Navisworks.Api.Application.ActiveDocument.SelectionSets.ResolveReference(reference) == Autodesk.Navisworks.Api.Application.ActiveDocument.SelectionSets.RootItem.Children[0]) { MessageBox.Show("resolved item matches the first child item"); } //remove the SavedItem bool val = Autodesk.Navisworks.Api.Application.ActiveDocument.SelectionSets.Remove(item); //check resolved reference is no longer valid if (Autodesk.Navisworks.Api.Application.ActiveDocument.SelectionSets.ResolveReference(reference) == null) { MessageBox.Show("SavedItem no longer exists"); } } }
Inheritance Hierarchy
System..::..Object
Autodesk.Navisworks.Api..::..NativeHandle
Autodesk.Navisworks.Api..::..SavedItem
Autodesk.Navisworks.Api..::..SelectionSet
Autodesk.Navisworks.Api..::..NativeHandle
Autodesk.Navisworks.Api..::..SavedItem
Autodesk.Navisworks.Api..::..SelectionSet