Skip to content

Instantly share code, notes, and snippets.

@teocomi
Created May 8, 2018 10:55
Show Gist options
  • Save teocomi/2dd933b68f2b12212e7fbdf9c657eca0 to your computer and use it in GitHub Desktop.
Save teocomi/2dd933b68f2b12212e7fbdf9c657eca0 to your computer and use it in GitHub Desktop.
#Given a level name or a list or level names, return the matching level/s found
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
def getLevelsByName(levelNames):
doc = DocumentManager.Instance.CurrentDBDocument
allLevels = FilteredElementCollector(doc).OfClass(Level).ToElements()
return loopSublists(levelNames, allLevels)
def loopSublists(data, allLevels):
out = []
if type(data) is list:
for d in data:
out.append(loopSublists(d, allLevels))
elif data != None:
for i in allLevels:
if i.Name == data:
out = i
break
else:
continue
return out
OUT = getLevelsByName(IN[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment