Looking for efficiency: Filter elements that have parameter that has value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
ElementParameterFilter fil = new ElementParameterFilter(ParameterFilterRuleFactory.CreateSharedParameterApplicableRule("SomeParameter"));
FilteredElementCollector elements = new FilteredElementCollector(m_CommandData.Application.ActiveUIDocument.Document).WherePasses(fil).WhereElementIsNotElementType();
so first im using the ParameterFilterRuleFactory to get an collection of all elements that contain a certain parameter by name "SomeParameter".
EDIT: for clarification; at this point it is a project parameter im searching, therefore i used the string of the parameter and not the ID
Now in the next step i am looking for a way that is performance wise the best solution to filter all those elements that actually have any value assigned to that parameter.
I could just iterate over all elements in the collector by foreach element and check if the parameter is empty and so on and so forth, but i doubt if this would be verry efficient for big revit models tot contain a lot of elements where most of them wont have an value assigned.
i was wondering if there is a more efficient way to do this.
e.g. could i somehow already cast some check within the filteredelementcollector to already get rid of all elements that dont have a value assigned within the given parameter ?
EDIT:
As usual having a short break and writing this topic brings insight and new ideas... already fixing it before the first answer 😉
in case anyone was looking for it:
i ended up combining the ParameterValueProvider (FilterStringGreater) with the ParameterFilterRuleFactory and made them into a LogicalAndFilter as an combined result.
now i get only the elements that have the parameter AND have a value assigned to them