Host of Tag

Hopefully this is an easy one.

How would I select the host elements for a list of tags or read the values inside the tags?

So there are two ways since you are potentially dealing with two conditions. Either the tag is tagging an element in a host file or a linked file. To get the element being tagged that is in the host file just use this code:

elementId = tag.TaggedLocalElementId

and then you can use the returned value to select the element:

element = doc.GetElement(elementId)

Now if you are dealing with linked models and you want the element from a linked model do this:

linkelementId= tag.TaggedElementId

and then again to get the element:

element = linkedDoc.GetElement(linkelementId)

To read text value from the tag just do:


This should do.

Thanks Konrad!

I am particularly looking at elements in the host file and tag.TagText

Let me see if I can throw that into a node.

Hi Konrad and Timon

I cant make the tag.TagText code to work.

Are you using the codes in Code Block or Python?

I thrived both methods without any luck.

A little help who be a predicated!



Fellas, like I said its relatively easy to do. Let’s take Furniture tags for example, and of course we talked about local host element and not one in a linked file. Here’s an example:


My idea is to make a definition to delete all tags in a project containing a question mark.

This piece is very helpfull. <span style=“color: #1a0dab;”> </span>

Many thanks!

CaptureCopy pated the whole thing - but still not working for me :frowning:

Are you in the near future goring to include this function in a Custom Note?


what is the error message?

Hi Peter




A little slow on replying to this thread, but here is what I came up with that works for me.

Thank you Archi-Lab for the “delete elements” node


Great!! Timon

I find this defi. very useful!


Hi Timon

I have tested your definition.

It’s appear to only work if the TagText comes from a instance parameter and if there only are one tag of a category loaded into the project.

Do you have the same issues?



I haven’t had time to figure out why, but it crashes continually. It’s my first attempt at writing python and I’m going to try to use Konrad’s code, he’s much more proficient.

Managed to get this working. Modified Konrads code a bit so it also outputs the list of tags with the host and text (To avoid any chance of the list order being different and deleting the wrong things).

Delete Empty Tags

Konrad, I like your way of processing lists in python much better than for…in :slight_smile:

I am happy you guys were able to make it work.


I am glad you found those useful. I would only add one more thing to the code that I posted here. If user ever decided that they wanted to execute this code on a single item then ProcessList definition would fail. I usually do a simple check for whether an IN[] is a list or not: if isinctance(IN[0], list): then use ProcessList() else use some definition directly on the input.

Hope this helps