Selection set creation from outside Navisworks....

Selection set creation from outside Navisworks....

Murali_Kandasamy
Explorer Explorer
348 Views
2 Replies
Message 1 of 3

Selection set creation from outside Navisworks....

Murali_Kandasamy
Explorer
Explorer

Hi,

 

I want to create selection sets from outside Navisworks.... I have list of Components OIDs, using that needs to create selectionsets, I already having program for creating Searchset, this request is for "Selectionsets"

 

 

 

Thanks

Murali. K

0 Likes
349 Views
2 Replies
Replies (2)
Message 2 of 3

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @Murali_Kandasamy ,

 

Try using this below sample code

 Document doc = Autodesk.Navisworks.Api.Application.ActiveDocument;
            DocumentSelectionSets oSets = doc.SelectionSets;

            Search s = new Search();
            SearchCondition sc = SearchCondition.HasPropertyByDisplayName("Item", "Name");
            s.SearchConditions.Add(sc.EqualValue(VariantData.FromDisplayString("ROOF_3")));
            s.Selection.SelectAll();
            s.Locations = SearchLocations.DescendantsAndSelf;

            ModelItemCollection from = s.FindAll(doc, false);
            doc.CurrentSelection.Clear();
            doc.CurrentSelection.CopyFrom(from);

            SavedItem newItem = new SelectionSet(doc.CurrentSelection.SelectedItems);
            newItem.DisplayName ="SelectionSetName";
            Autodesk.Navisworks.Api.Application.ActiveDocument.SelectionSets.InsertCopy(0, newItem);

Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 3

Murali_Kandasamy
Explorer
Explorer

Thanks Mr. Naveen, let me check and update you... 

0 Likes