Skip to content

Instantly share code, notes, and snippets.

Created May 21, 2018 11:42
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
#Given an element Id or a list or elementIds, return the matching tags/s found
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 *
def getTagsByElementId(beamIds):
doc = DocumentManager.Instance.CurrentDBDocument
allTags = FilteredElementCollector(doc).OfClass(IndependentTag).ToElements()
return loopSublists(beamIds, allTags)
def loopSublists(data, allTags):
out = []
if type(data) is list:
for d in data:
out.append(loopSublists(d, allTags))
elif data != None:
matches = []
for i in allTags:
if str(i.TaggedElementId.HostElementId) == str(data):
# if multiple matches nest them
if len(matches) == 1:
out = matches[0]
elif len(matches) == 0:
out = None
out = matches
return out
OUT = getTagsByElementId(IN[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment