Oct 15, 2022
Get TitleBlock from Sheet.
Learn how to get TitleBlocks from ViewSheet with ElementParmaeterFilter in Revit API
How to Get Title Blocks from Sheets with Revit API❓
There are multiple ways of getting TitleBlocks from Sheets:
👉️ Get visible TitleBlocks with FilteredElementCollector(doc, view.Id) <- Slower
👉️ Get all TitleBlocks and look at their OwnerViewId
I would recommend using a function with
ElementParameterFilter, since it's already written for you and it's a no-brainer.
1️⃣ Get TitleBlock with ElementParameterFilter
For this method we will need to create ElementParameterFilter and use it in FilteredElementCollector. This is probably the most efficient way to get TitleBlocks from sheets.
💡 Also notice that there are differences in Revit API for FilterStringRule, but I accounted for it in my snippet.
2️⃣ Get visible TitleBlocks with FilteredElementCollector(doc, view.Id)
There is an alternative method to use
FilteredElementCollector and provide
ViewSheet.Id as a second argument to get elements visible in that sheet.
💡 This is much easier approach but it will cost in execution time!
I was curious about the difference between these two methods, so I put them to the test.
The second method is slower because it has to load up the view to analyze what elements are visible and it comes at a cost!
💡I used a Revit project that is ~500mb and I used similar logic of getting title blocks,
👇 Here are the results.
🧮 As you can see there is a huge difference.
252s- It's ~2500% difference!
The difference is going to be less on smaller projects. But on large projects where it takes longer times to render views, it might become an issue.
The problem is that whenever you provide
FilteredElementCollector it has to partially render the view. While on a smaller projects this difference can be little, on large projects it might become an issue.
I was too lazy to make separate buttons for each method—so my comparison isn't perfect—but with such a huge difference, who cares?
You can take a look at the code below that I quickly wrote to see how I made comparison