Community
Navisworks API
Welcome to Autodesk’s Navisworks API Forums. Share your knowledge, ask questions, and explore popular Navisworks API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using existing searchsets w/ API

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
amit.dayan
695 Views, 4 Replies

Using existing searchsets w/ API

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.

4 REPLIES 4
Message 2 of 5
amit.dayan
in reply to: amit.dayan

appinfo did the trick. got what i needed.

Message 3 of 5

@amit.dayan Can you please share the solution in details please, facing the same issue

Message 4 of 5

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.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 5 of 5

Yes Thanks @naveen.kumar.t It Works.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report