Add search selectionset in .Net

By Xiaodong Liang

The construction method of SelectionSet provides the way to add a search object. Thus you can create the selectionset with the search. Following is a small demo code.

void AddSearchSelectionSetByNet()    {        // 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;             // create a selectionset with the search condition        SavedItem newItem =             new SelectionSet(s);        newItem.DisplayName = "My Walls";             // add this selection set to selection set collection        Autodesk.Navisworks.Api.Application.ActiveDocument.            SelectionSets.InsertCopy(0, newItem);    }

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading