Created
May 8, 2018 10:55
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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