Element Collector inaccurate results when using OpenAndActivateDocument
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Note: This is duplicate post, I'm now posting under ADN account. I've redirected the other post's solution to this one.
I'm fairly confident I've found a bug in Revit API. When using OpenAndActivateDocument to open Revit doc, my view specific FilteredElementCollector is returning inaccurate result. The collector is picking up extra walls just above/below visible range of plan view. Using exact same code, but opening doc with OpenDocumentFile will return the proper result.
This code returns result of 4 walls in Level 1 view (this is NOT correct)
Dim doc = uiapp.OpenAndActivateDocument("C:\Users\Jon\Desktop\API test\Project1.rvt").Document
Dim collectorPlanViews As New FilteredElementCollector(doc)
collectorPlanViews.OfClass(GetType(ViewPlan))
Dim Level1View As ViewPlan = collectorPlanViews(0)
Dim collectorWalls As New FilteredElementCollector(doc, Level1View.Id)
collectorWalls.OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType()
MessageBox.Show(collectorWalls.Count & " walls in " & Level1View.Name, "API Test 2")
Note: If I put an random message box after opening the doc, the collector returns proper result.
Note 2: If the walls above/below are moved farther away from Level 1 view range, they are not collected.
This identical code (other than how doc is opened) returns correct result of 2 walls)
Dim doc = app.OpenDocumentFile("C:\Users\Jon\Desktop\API test\Project1.rvt")
Dim collectorPlanViews As New FilteredElementCollector(doc)
collectorPlanViews.OfClass(GetType(ViewPlan))
Dim Level1View As ViewPlan = collectorPlanViews(0)
Dim collectorWalls As New FilteredElementCollector(doc, Level1View.Id)
collectorWalls.OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType()
MessageBox.Show(collectorWalls.Count & " walls in " & Level1View.Name, "API Test 3")
doc.Close()
This is causing unexpected results through out my application when filtering objects per view.
Any thoughts on this?
Thanks,
Jon Albert
Developer Advocacy and Support +