Get Tag host element

Years later needed this! Here is the py code condensed:

import clr                                                  ## Load the Python Standard and DesignScript Libraries

import Revit

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

doc = DocumentManager.Instance.CurrentDBDocument            ##Current DOC

tags = UnwrapElement(IN[0])                                 ##The inputs to this node will be stored as a list in the IN variables.

TaggedElements=[]                                           ##Initialize the output list


TransactionManager.Instance.EnsureInTransaction(doc)        ##Get transaction manager fo rundo

for i in tags:                                                  ##For each tag 
        tagID = doc.GetElement(i.Id)                            ##Get the ID
        taggedID = doc.GetElement(tagID.TaggedLocalElementId)   ##Get the id of the tagged element
        TaggedElements.append(taggedID)                         ##Add it to the OUT list : )    

TransactionManager.Instance.EnsureInTransaction(doc)        ##End transaction if crash    

OUT = TaggedElements                                        ##Return tagged elements
3 Likes