Hi @chan_baek ,
Yes, it is possible. Please take a look at the code below.
Search s = new Search();
SearchCondition sc = SearchCondition.HasPropertyByDisplayName("Item","Name");
s.SearchConditions.Add(sc.EqualValue(VariantData.FromDisplayString("Basic Wall")));
s.Selection.SelectAll();
s.Locations = SearchLocations.DescendantsAndSelf;
SavedItem newItem = new SelectionSet(s);
newItem.DisplayName = "MySearchSetName";
Autodesk.Navisworks.Api.Application.ActiveDocument.SelectionSets.InsertCopy(0, newItem);
@naveen.kumar.t Thanks for helping. Then, Can I Create folder too?
I solved it. Thank you.
Search s = new Search();
SearchCondition sc = SearchCondition.HasPropertyByDisplayName("Item", "Name");
s.SearchConditions.Add(sc.EqualValue(VariantData.FromDisplayString("Basic Wall")));
s.Selection.SelectAll();
s.Locations = SearchLocations.DescendantsAndSelf;
SavedItem newItem = new SelectionSet(s) { DisplayName = "MySearchSetName" };
// 폴더 생성
SavedItem folder = new FolderItem { DisplayName = "aaaa" };
// 폴더를 SelectionSets 루트에 추가
NavisApp.ActiveDocument.SelectionSets.InsertCopy(0, folder);
var doc = Autodesk.Navisworks.Api.Application.ActiveDocument;
var selectionSets = doc.SelectionSets; // DocumentSelectionSets
var rootFolder = selectionSets.RootItem; // SelectionSets 트리의 루트 SavedItem
SavedItem savedFolder = null;
foreach (SavedItem item in rootFolder.Children)
{
if (item is FolderItem folderItem && folderItem.DisplayName == "aaaa")
{
savedFolder = folderItem;
break;
}
}
// 폴더의 IndexPath 가져오기
//Collection<int> index = NavisApp.ActiveDocument.SelectionSets.CreateIndexPath(savedFolder);
// 폴더 안에 SearchSet 삽입 (폴더의 IndexPath를 기준으로 Insert)
NavisApp.ActiveDocument.SelectionSets.InsertCopy((GroupItem)savedFolder, 0, newItem);