- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Afternoon All,
I'm working with Revit 2020. I was curious to see if there are any known issues where attempting to iterate over a FilteredElementCollector may intermittently generate an exception? In my case, I'm constructing a FilteredElementCollector that uses an ElementIntersectsSolidFilter and a LogicalAnd containing several BuiltInCategories.
Having constructed the collector and applied filters, it seems that any form of iteration has the potential to generate an exception that references the FilteredElementIterator. Here's the basic format I've been using (nothing complicated, as you can see):
//Declare collector and apply filter
FilteredElementCollector myCollector = new FilteredElementCollector(doc);
myCollector.WherePasses(myFilter);
//Iterate over the collector
foreach(Element myElement in myCollector)
{
//Do stuff with the passing elements
}
Oddly enough, however, I have observed in testing that the same code may alternately error out or execute perfectly in two consecutive tests with no change to the code. As a result, I do not have a reproducible test case, because I cannot "force" a configuration where it always reliably fails. I've been through several full-day marathons of testing, debugging, and tweaking the code. I always finish the day believing I've resolved it and then 3 days later after many successful uses it unexpectedly errors out again with no apparent cause.
My first assumption is always that I have an error in my code. However, the fact that it can fail and then run successfully back to back with 100% identical conditions makes me wonder if there is a bug or instability that is beyond my reach.
I've used FilteredElementCollectors extensively for many different purposes from Revit 2017 all the way up to Revit 2020 and have never before observed this behavior. Any thoughts on this???
Solved! Go to Solution.