Query Level by String Name


As the title says, is it possible to query a Level by String name? As I want to use an Excel Spreadsheet to Query specific Levels, I cannot use the Level query by Dropdown menu.


Yes it is:

#Copyright© 2015, Konrad K Sobon

@arch_laboratory, http://archi-lab.net

import clr
from Autodesk.DesignScript.Geometry import *

Import DocumentManager and TransactionManager

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

Import RevitAPI

import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument

#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN
levelName = IN[0]

level = None
message = "Name doesn’t match any levels in \n the project. Pick a different one"
allLevels = FilteredElementCollector(doc).OfClass(Level).ToElements()
for i in allLevels:
if i.Name == levelName:
level = i

if level == None:
OUT = ‘\n’.join(’{:^35}’.format(s) for s in message.split(’\n’))
OUT = level



I think Andreas added a great little node to the clockwork package recently called “All Elements Of Name” which if combined with a map node, saves you a lot of effort:



Also, added it to the archi-lab package for easy access.



Nice! I like that solution better. There are so many nodes in his package. I don’t even know then all. :slight_smile:


Cheers guys, works great!


Hi Konrad/Dimitar

I have installed Clockwork for Dynamo 0.7x but I can’t find that node All elements of Name.

Was it in a previous package?





I renamed it. I think it’s called Elements.FilterByName now.