Navisworks API

Posts: 11
Registered: ‎10-18-2009
Message 1 of 2 (333 Views)

How to save a Search to Selection set by Navisworks API

333 Views, 1 Replies
06-05-2012 10:52 PM

// New a Search

Navisworks.Search s = new Navisworks.Search();


// Add a search Condition

Navisworks.SearchCondition scName = Navisworks.SearchCondition.HasPropertyByDisplayName("Item", "Name");

scName = scName.EqualValue(Navisworks.VariantData.FromDisplayString(strItem));



// Get Search Result

Navisworks.ModelItemCollection searchRst = s.FindAll(Navisworks.Application.ActiveDocument, false);


if (searchRst.Count > 0)


// Save to current Search



// Create Search Set

        ComApi.InwOpSelectionSet2 ss = state.ObjectFactory
               (ComApi.nwEObjectType.eObjectType_nwOpSelectionSet) as ComApi.InwOpSelectionSet2; = selCompName;


// Add Find Spec

       ComApi.InwOpFindSpec nwFindSpec  = state.ObjectFactory

              (ComApi.nwEObjectType.eObjectType_nwOpFindSpec) as ComApi.InwOpFindSpec;


// Set Find spec with Current Search

        nwFindSpec = state.CurrentFindSpec;


        ss.ImplicitFindSpec = nwFindSpec;


// Add Search Set to Selection Sets




ADN Support Specialist
Posts: 1,233
Registered: ‎06-12-2011
Message 2 of 2 (285 Views)

Re: How to save a Search to Selection set by Navisworks API

08-01-2012 01:12 AM in reply to: ctci20299

In this case, Search is a .NET object while InwXXX are COM objects. Although COM interop allows you communicate between COM API and .NET API, this does not mean the COM objects can be assigned to the .NET objects.


Please refer to the two blogs. I think they answered your question.



Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community