Hello,
I have many searchsets that are/will be defined by the user through navisworks UI.
I would like to use these existing searchsets for further actions. preferably reach those existing searchsets by their display name (as defined by their creator-the user).
Every written/help material I've found so far (documentation, xiaodong's blog..) only refered to generating "new searchsets" by defining conditions on the code.
any guidance will be appreciated.
Solved! Go to Solution.
Solved by amit.dayan. Go to Solution.
@amit.dayan Can you please share the solution in details please, facing the same issue
Hi @ritikk_TWEMT4ENWAYA ,
Please take a look at this below code
Document doc = Autodesk.Navisworks.Api.Application.ActiveDocument;
SavedItemCollection searchAndSelectionSets=doc.SelectionSets.Value;
IList<SavedItem> requiredSearchSets = new List<SavedItem>();
foreach(SavedItem savedItem in searchAndSelectionSets)
{
SelectionSet selectionSearchSet = savedItem as SelectionSet;
if(selectionSearchSet.HasSearch)
{
//Check whether SelectionSet.HasSearch value
//If "true", it is a "Search Set"
//If "false", it is a "Selection Set"
requiredSearchSets.Add(selectionSearchSet);
}
}
foreach(SavedItem savedItem in requiredSearchSets)
{
SelectionSet searchSet=savedItem as SelectionSet;
ModelItemCollection modelItemCollection= searchSet.GetSelectedItems();
foreach(ModelItem modelItem in modelItemCollection)
{
//Access Search Set Model Items here
}
}
I hope this helps.