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
There seems to be a few issues - TaggedLocalElementId was removed from the API in 2023, the correct method is now GetTaggedLocalElementIds() which returns a list of elements.
The current archilab node is still using the depreciated attribute - you could add an issue to the GitHub here
# From archilab Tag Host Element custom node
def GetHostElement(tag):
if tag.Category.Name == "Room Tags":
hostElemId = tag.TaggedLocalRoomId
else:
hostElemId = tag.TaggedLocalElementId
return doc.GetElement(hostElemId)
hi, i just found out that TaggedLocalElementId is deprecated
[ObsoleteAttribute("This property is deprecated in Revit 2022 and will be removed in a later version of Revit. We suggest you use the `GetTaggedLocalElementIds()` method instead.")]
public ElementId TaggedLocalElementId { get; }
You can use the OOTB nodes Tag.TaggedElement or this python code:
all_pipes = uwlist(IN[0])
TransactionManager.Instance.EnsureInTransaction(doc)
all_elements_name = []
all_elements = []
for pipe in all_pipes:
tagged_el = pipe.GetTaggedLocalElements()
for i in tagged_el:
all_elements_name.append(i.Name)
all_elements.append(i)
TransactionManager.Instance.TransactionTaskDone()
OUT = all_elements_name, all_elements