Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Filter for elements where parameter unequal to string

m.mastbergen
Explorer
Explorer

Filter for elements where parameter unequal to string

m.mastbergen
Explorer
Explorer

I want to get each element that does not yet have "theValue" for a specific parameter. In the following code example i filter for elements that DO have the value, how do i reverse/invert this to get what i need?

FilteredElementCollector fec = new FilteredElementCollector(doc);
var elements = fec.ToElements();           
var id = elements[0].LookupParameter("IfcName").Id;
ParameterValueProvider pvp = new ParameterValueProvider(id);            
var fsc = new FilterStringEquals();            
var ruleValue = "theValue";           
var frule = new FilterStringRule(pvp, fsc, ruleValue, false);            
var filter = new ElementParameterFilter(frule);            
fec = fec.WherePasses(filter);

 

 

0 Likes
Reply
Accepted solutions (1)
306 Views
1 Reply
Reply (1)

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

Hi @m.mastbergen ,

 

You can use the FilterInverseRule

https://www.revitapidocs.com/2023/bd21b884-c026-5a16-4470-72172b71db4a.htm

 

Here is the sample code

https://spiderinnet.typepad.com/blog/2011/07/elementparameterfilter-using-filterinverserule-to-filte... 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network