Hiding all the selected items from a given Navisworks model is very straight-forward. All that needs to be done is to put the selected items into a new collection (which is like a container for the selected items) and pass this new collection to the ActiveDocument.Models.SetHidden() method. The code is provided below for direct use -
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Text;
//Add two new namespaces
using Autodesk.Navisworks.Api;
using Autodesk.Navisworks.Api.Plugins;
namespace BasicPlugIn
{
[PluginAttribute("BasicPlugIn.ABasicPlugin",
"ADSK",
ToolTip = "BasicPlugIn.ABasicPlugin tool tip",
DisplayName = "Sample Plugin")]
public class ABasicPlugin : AddInPlugin
{
public override int Execute(params string[] parameters)
{
// Create hidden collection
ModelItemCollection hidden = new ModelItemCollection();
// Add all the items that are visible to visible collection
hidden.AddRange(Autodesk.Navisworks.Api.Application.
ActiveDocument.CurrentSelection.SelectedItems);
// hide the remaining items
Autodesk.Navisworks.Api.Application.
ActiveDocument.Models.SetHidden(hidden, true);
return 0;
}
}
}