Can somebody tell me a way of collecting all the model lines in a project using Python?
The code below collects all lines in project which I think includes detail lines? This is too slow on a large project that has got a bit messy.
import clr
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
#The inputs to this node will be stored as a list in the IN variables.
toggle = IN[0]
collector = []
if toggle == True:
collector.append(FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Lines).WhereElementIsNotElementType().ToElements())
else:
pass
#Assign your output to the OUT variable.
OUT = collector
Sorry, I was too fast with this. It seems not all classes in the API can be used to with the OfClass filter, where the ModelLine is one of these. Here the remark from the API:
import clr
#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument
#---###Start scripting here:###---#
mc = FilteredElementCollector(doc).OfClass(CurveElement).ToElements()
OUT = []
for i in mc:
ct = i.CurveElementType
if ct == CurveElementType.ModelCurve:
OUT.append(ct)
else:
OUT.append('This is a Detail Line')