SelectionSets is a collection. It can contain Folder and common SelectionSet. A Folder is a GroupItem that can include common SelectionSet as well. The code below is a demo on how to create a common SelectionSet and a Folder, and how to move the common set to the folder.
public void testSelectionSet()
{
Document oDoc =
Autodesk.Navisworks.Api.Application.ActiveDocument;
// get the selection sets
DocumentSelectionSets oSets =
oDoc.SelectionSets;
// create a search and conditions
Search s = new Search();
SearchCondition sc =
SearchCondition.HasPropertyByDisplayName("Element",
"Category");
s.SearchConditions.Add(
sc.EqualValue(VariantData.FromDisplayString("Walls")));
//set the selection to everything
s.Selection.SelectAll();
s.Locations =
SearchLocations.DescendantsAndSelf;
SavedItem newItem = new SelectionSet(s);
newItem.DisplayName = "MySearchSet";
//add to the end
oSets.AddCopy(newItem);
//folder
FolderItem oFolder = new FolderItem();
oFolder.DisplayName = "MyFolder";
// add to the end
oSets.AddCopy(oFolder);
try
{
//index of the common selection set
int indexOfSaveditem = oSets.Value.Count - 2;
// move the selection set to the folder
oSets.Move(oSets.RootItem, indexOfSaveditem,
(GroupItem)oSets.Value.Last<SavedItem>(), 0);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}