I have a Search with multiple SearchCondition objects added. By default, conditions added create an "AND" style search.
Is there a way to do an "OR" style search?
More specifically, I have a list of element ids, and I want to know if it is possible to search for them all at once.
If not, then I suppose I could create a speparate search for each element.
Solved! Go to Solution.
I assume you are using .NET API. This needs SearchCondition group. It is "AND” within one group. It is "OR" among groups. The code below is tested with the SDK sample model: gatehouse.nwd.
//Create a new search
Search s = new Search();
//SearchCondition1 of group1:the item is required
SearchCondition oGroup1_SC1 = SearchCondition.HasPropertyByDisplayName("Item", "Required");
oGroup1_SC1 = oGroup1_SC1.EqualValue( VariantData.FromBoolean(true));
//SearchCondition2 of group1:the item's DWG handle is 16C17
SearchCondition oGroup1_SC2 = SearchCondition.HasPropertyByDisplayName("Entity Handle", "Value");
oGroup1_SC2= oGroup1_SC2.EqualValue( VariantData.FromDisplayString("16C17"));
//SearchCondition1 of group2: the item is NOT required
SearchCondition oGroup2_SC1= SearchCondition.HasPropertyByDisplayName("Item", "Required");
oGroup2_SC1 = oGroup2_SC1.EqualValue(VariantData.FromBoolean(fal
//SearchCondition2 of group2: the item's DWG handle is 17C2E
SearchCondition oGroup2_SC2 = SearchCondition.HasPropertyByDisplayName("Entity Handle", "Value");
oGroup2_SC2 = oGroup2_SC2.EqualValue(VariantData.FromDisplayStri
System.Collections.Generic.List<SearchCondition> oG1 = new System.Collections.Generic.List<SearchCondition>()
System.Collections.Generic.List<SearchCondition> oG2 = new System.Collections.Generic.List<SearchCondition>()
// add groups to SearchConditions
//highlight the items
ModelItemCollection searchResults = s.FindAll(Autodesk.Navisworks.Api.Application.Acti
Developer Technical Services
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register