FilteredElementCollector only works sporadically when collecting ViewSheet
Not applicable
03-12-2018
03:47 AM
I have a plugin that contains the following code snippet
var document = commandData.Application.ActiveUIDocument.Document;
var collector = new FilteredElementCollector(document); var views = collector.OfClass(typeof(ViewSheet)).ToElements().Cast<ViewSheet>();
Testing against the rac_basic_sample_revit project that comes supplied with Revit 2018.2, I sometimes get six valid ViewSheets returned, as expected, and other times I just get six nulls. I get similar unpredictable results querying other types.
Can anybody shed any light on to what I may be doing wrongly?
Link copied