- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a lot of code where filtering is done on the element name like:
AssemblyInstance assemblyInstance = new FilteredElementCollector(doc)
.OfClass(typeof(AssemblyInstance))
.Cast<AssemblyInstance>()
.Where(assembly => assembly.Name == "SE51")
.FirstOrDefault();
In previous versions of the API it seems like it was possible to make a slow filter on element name as explained here by using either of the these builtinparameters as filters:
- BuiltInParameter.ALL_MODEL_NAME
- BuiltInParameter.DATUM_TEXT
- BulitInParameter.ELEM_NAME_PARAM
Example:
FilterRule rule = ParameterFilterRuleFactory.CreateEqualsRule(new ElementId(BuiltInParameter.DATUM_TEXT), "SE51");
ElementParameterFilter filter = new ElementParameterFilter(rule);
AssemblyInstance assemblyInstance = new FilteredElementCollector(doc)
.OfClass(typeof(AssemblyInstance))
.WherePasses(filter)
.Cast<AssemblyInstance>()
.FirstOrDefault();
However this does not work in 2022 and up.
Is there a way in the current API to make a filter on the name of an element?
Solved! Go to Solution.