Host of Tag


#1

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?


#2

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:

tag.TagText

This should do.


#3

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.


#4

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!

/Jesper

 


#5

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:

Capture


#6

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!


#7

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?

 


#8

what is the error message?


#9

Hi Peter

Capture


#10

 

 

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

deleteEmptyTags


#11

Great!! Timon

I find this defi. very useful!

Thanks!!


#12

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?

/Jesper

 


#13

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.


#14

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:


#15

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

Joseph,

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