Hi alll,
is it just me or the Sheet.TitleBlocs node is incredibly slow?
Do it in Python instead:
import clr
clr.AddReference("RevitNodes")
from System import Array
from System.Collections.Generic import *
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
doc = DocumentManager.Instance.CurrentDBDocument
# Get all titleblocks in model
all_tblocks = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_TitleBlocks).WhereElementIsNotElementType().ToElements()
#Input list of sheets to get titleblocks of
sheets = UnwrapElement(IN[0])
# Function for filtering all model titleblocks by sheet number of input sheet
def sht_tblock(sht, all_tblocks):
# Get sheet num of sheet
sheet_num = sht.SheetNumber
# filter by sheet number
tblock = list(filter(lambda x: x.LookupParameter('Sheet Number').AsString() == sheet_num, all_tblocks))
return tblock
titleblocks = []
for sheet in sheets:
# Call function
titleblocks.append(sht_tblock(sheet, all_tblocks)[0])
OUT = titleblocks
Thanks @haganjake2, i can retrieve them (python or other packages) but i’m still curious to see if it’s just me.
Is this the OOTB node you are referencing?
Yes boss
I have never noticed any slow speeds with it (the OOTB is based on my Rhythm node actually).
All it is doing is a view-based collection for title blocks which should be very quick.
What is strange is, I believe a FilteredElementCollector
should be a bit more efficient that iterating over the parameters as demonstrated above in python.
Another way with OwnerViewId
property
import sys
import clr
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
sheets = UnwrapElement(IN[0])
all_tblocks = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_TitleBlocks).WhereElementIsNotElementType().ToElements()
out = []
for sheet in sheets:
filter = System.Predicate[System.Object](lambda x : x.OwnerViewId == sheet.Id)
tblks_in_view = all_tblocks.FindAll(filter)
out.append(tblks_in_view)
OUT = out
I am using the OOTB node as well, and basically is regenerating (opening?) all sheets that you pass to it.
Is this normal?
It takes long time if you have too many sheets…
Also, of course you cannot cancel / stop it?
Do I need to force quit Revit?
Thank you
… and… it crashed.
I have experienced this before using the ootb node as I believe it uses a view specific filtered element collector.
As was identified before a far easier way that does not open any sheets is to use the viewids of titleblocks.