Get Tag host element



Is it possible to get the tag host element and change the tag based on the element parameters?

Yes this is possible. Below is a python script that will take tags and give you the corresponding tagged elements (hosts).


1 Like

To Set the Tag Types, use GetParameterValueByName on the Tag hosts to pull in the test data, run whatever tests you need on the data, then use Element.SetParameterValueByName with the Tag Elements, “Type” as the ParameterName, and Family Types as the value to set the tag types for each element.



I can’t thank you enough!

Can’t wait to try it! I will also try to understand a little bit better the python code so i can pursue on writing my own code in the future and share some nodes with the community.

If you don’t mind i will bug you with some questions about the code.

Thanks a lot Ben, this seems to be working nicely. The output I’m getting though is the element name and the ID. How can we just get the ID? I don’t think it’s a problem, but was just curious.

Easy way…follow the Python node with Element.Id node.

Python way…see image below (slight mod of previous post)


Thanks Ben, in my case I was getting the element name (type) and ID as follows so I suppose that’s what TaggedLocationElementID returns. I thought that passing this to a node that accepts “elements” was going to be a problem but it isn’t. For some reason I’ve seen other nodes return just the element ID highlighted in green but in this case it is also returning the type. At least it doesn’t seem to interfere downstream.


Sorry for the confusion. I originally had the code sending back ElementIds, but then I modified it to send back the Elements, but i never changed the variable names so i can see how that might leave someone scratching their heads.

i’ve never seen just the green ids returned…examples?

I can’t think of a case off the top of my head, maybe I’m imagining things (wouldn’t be the first time!). I’ll post if I find one but after all it doesn’t matter as it’s working properly. It was just a misconception on my side most probably :slight_smile:

Hi All. Dynamo_2015-11-09_15-28-56


I noticed this thread does not handle tags that are not “independent”. Specifically, I am dealing with Spatial Element tags. It looks like Revit’s API has no association between Spatial Element Tags and the Elements which they tag. So far, there is no 100% surefire way to get an element-tag association that I could find. (looked at the buildingcoder’s blog post from 2009 and it suggests some WEIRD workarounds)

See: Am I out of luck or is there a more up-to-date resource?



EDIT: The custom python script is taken out of Archilab’s (grimshaw) “Get Tagged Element ID” Node.Dynamo_2015-11-09_15-35-04

The Room and Space tags are actually easier than any other kind of tag… in the API they have special properties. For a Room Tag, use the RoomTag.Room property to get the Room Element being tagged. For a Space Tag, use the SpaceTag.Space property to get the Space Element being tagged. See snapshots below from the API help and Snoop…

Hi Ben,

I am new to dynamo and api. I am trying to get dynamo to report the value a room tag is holding. I can see from the screen shot above, I will need to use RoomTag.Room property in the python script you wrote above. Can you let me know where it should go or what it is replacing?

Thanks in advance.



See attached image:


Hi Ben,

thanks for that. I will give it a try.



I know this is an old post. I am trying to get the host elements of several User Keynote Tags. There seemed to be two promising solutions in this post: The Python script and the Archi-lab node. When I try the Archi-lab node, I get an Obsolete warning and it won’t run.
I am in Revit 2019 and Dynamo

When I type in the Python code instead, it fails with this warning:

I am pretty sure I typed the code exactly as shown above. Here is my Python window:

So is it still possible to get the host of a tag? (Keynote tag specifically)? and if so, what do I need to do differently that has changed since this post was made?

Thanks very much.

@Paul_Aubin These 4 lines of code look indented:

That was it! Thanks for the speedy response! Working great now.

1 Like

@Paul_Aubin You can actually get rid of the 4 lines as you are not using any RevitNodes or doing any geometry conversion. You don’t need TransactionManager.Instance.EnsureInTransaction(doc) and TransactionManager.Instance.TransactionTaskDone() either, because you are not changing the Revit Database

Sounds good. Does it hurt anything to declare things like that and then not use them? Or is it more about being efficient and not calling things into memory that you don’t need or use?


Hello guys,

I am not very familiar with python, but I retyped the code above and it doesn’t work here.

I am trying to get the id/host of an area tag.


Any ideas???

import clr
from Autodesk.DesignScript.Geometry import *

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

import Autodesk
from Autodesk.Revit.DB import *

import Revit

dataEnteringNode = IN

tags = UnwrapElement(IN[0])

taggedelements =
doc = DocumentManager.Instance.CurrentDBDocument


for i in tags:
tagID = doc.GetElement(i.Id)
taggedElem = doc.GetElement(tagID.TaggedLocalElementId)


OUT = taggedelements,taggedelementids