How do I get the list of Levels using Python?

I am trying to get the list of Levels using Python in order to create a plan per level & phase.
I get the Phases using doc.Phases. ( doc = revit.ActiveUIDocument.Document)
I could not find the way to access the Levels in a similar way.
Thanks , Jonathan.

1 Like

@jonathan.talisman

   import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference('DSCoreNodes')
import DSCore 
from DSCore.List import *
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
out = []
#Assign your output to the OUT variable.
OUT =  FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType().ToElements()
14 Likes

Thanks @fathygad .
I can undestand from the naming convention the FilteredElementCollector.ofCategory.
What is the purpose of the WhereElementIsNotElementType().ToElements() part ?
Jonathan

@jonathan.talisman IF U don’t use u will get the element (Level) and the Element type , so if u have 10 level u will get 20 item output 10 for levels them selves and other 10 for their types.

2 Likes

Thanks