With COM API, you could setup an InwOpSelection and add the paths which is the result of the find. And call State.CurrentSelection = your InwOpSelection. While in .NET API, current selection is exposed as a document part CurrentSelection. The highlighting objects is to change the selected items of CurrentSelection.
The code below shows the ways to highlight in COM and .NET.
using Autodesk.Navisworks.Api; using ComApi = Autodesk.Navisworks.Api.Interop.ComApi; using ComApiBridge = Autodesk.Navisworks.Api.ComApi;
// highlight objects private void highlight() { Document oDoc = Autodesk.Navisworks.Api.Application.ActiveDocument; // assume we get two model items ModelItem oItem1 = oDoc.Models[0].RootItem.DescendantsAndSelf. ElementAt(1); ModelItem oItem2 = oDoc.Models[0].RootItem.DescendantsAndSelf. ElementAt(2); // create ModelItemCollection ModelItemCollection oSel_Net = new ModelItemCollection(); oSel_Net.Add(oItem1); oSel_Net.Add(oItem2); // highlight by .NET API oDoc.CurrentSelection.SelectedItems.CopyFrom(oSel_Net); //highlight by COM API ComApi.InwOpState10 state = ComApiBridge.ComApiBridge.State; ComApi.InwOpSelection comSelectionOut = ComApiBridge.ComApiBridge.ToInwOpSelection(oSel_Net); state.CurrentSelection = comSelectionOut; }

Leave a Reply to davidCancel reply