Announcements

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

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

Filter for elements where parameter unequal to string

1 REPLY 1
SOLVED
Reply
Message 1 of 2
m.mastbergen
304 Views, 1 Reply

Filter for elements where parameter unequal to string

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);

 

 

Labels (5)
1 REPLY 1
Message 2 of 2

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

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

Post to forums  

Autodesk Design & Make Report