Element Tag Host no longer working

I’m trying to collect the element of the tag, but the Archilab node no longer seems to work. Where it almost seems as if some API has changed.

There’s another thread of the forum but this python script has the same issue with the ‘TaggedLocalElementId’ that the archilab node does - https://forum.dynamobim.com/t/get-tag-host-element/1817/34

can you share the python script?

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


I used Revit 2022
image

3 Likes

Thanks, the OOTB node is working.

I also tried your python code and got an error, but I am using 2024 and 2.19 (plus the nodes default to CPython3)

check the spelling, it’s working alright on my 2024

image