Automatically tag one element per pipe section/diameter

Hello there,

I want to create tags by selection for pipes but only one element of that particular pipe section like this:

But when I use the revit function “tag all” it will tag all elements of the pipe section.

Can someone tell me how to do this? I will upload the script wrote for this.

The next issue I experienced is that the tag-node tells me this warning: “Document has no attribute NewTag”

please help…


Your screenshot isn’t legible. Zoom in to one group of nodes and use the image export.
(Your screenshot will include everything including the nodes that are not on the screen.)

Which version of Revit do you use ?
There have been changes in the API between the different versions of Revit.

Thank you @Alban_de_Chasteigner,

I uploaded a new picture of the script and rearranged it a little bit.

I use an English version of Revit 2020. I hope this helps…

So I was thinking of maybe write a script to only tag the longest part in that particular section by diameter and offset. But that is not possible if there is only one length in that section I guess.

I’m also looking for the “lines” dynamo refers to in the watch-node

Any suggestions?


You’re not using the correct node for Revit 2020. Use the Create Independent Tag node instead.

Thank you for replaying so fast!

I changed the node but tells me the following:
Exeption: The typeId is not valid for this element
Parameter name: typeId

Are you sure you want to tag 44 items and provide a single coordinate (TagLocation) ?
To do this, you must use a longest lacing or a list level.

I’m totally not sure of that… lol.

I want it to look something like the first picure I uploaded and place the tag next to the element (in the middle)

Am I not using the right nodes for that?

Use the Element.GetLocation and Curve.PointAtParameter nodes to get the location points.
See below :

I always find it best to work on your graph in parts, rather than trying to accomplish the whole thing at once. Getting your tags correct will be much easier if you have your elements filtered first.

I would now group your pipes by System Name and Section. Section should split them up by branch and/or size for you. Then you can determine which pipe from each section you want to tag (longest, first, middle, etc.)

Once you have a pipe from each section you just need the midpoint to tag it.

Wow, you are really helpfull, thank you both!

I changed the nodes like @Alban_de_Chasteigner said and that worked fine.

I also found that I did not select the right family tag for that particular pipe so I got a typeId error. But that is all good now!

This is what I got so far:

So I have to slit up these elements even more you say? Lets see how I can do that…

1 Like

I’m sorry but I can not seems to get it working…

@Nick_Boyts can you show me what you mean exactly (by showing nodes e.g.)

I was thinking if a command like: If [element] [is connected] [to simmular] than… find longest

of something like that.

anyone suggestions?

Start with something like this:

Sorry @Nick_Boyts for this delay but I put this project away for a while…

So I tried this nodes you suggested wich creates a set of lists within a group (or several groups…)

So I have some more questions for that matter:
How can I filter/extract the wanted lists (sections) from that group?
How can I tag the filtered elements from this list/group?

Can you help me out please?

We need to see more of your graph to know where to help you. How do you determine which sections you need?

@Nick_Boyts It looks like there is a list for every element instead of per pipe.

I would like the tags to look something like this:
riool opdracht school 1.pdf (95.3 KB)

Not every pipe element has to be tagged…

Do you know what I do wrong here?

GroupByKey only groups elements into lists. It doesn’t create Revit Groups. However, you need to use no list levels on the first GroupByKey and @L2 on the second. Once you have your lists of elements by section you can take one element from each sublist and tag it. Be sure you’re grabbing pipe though, it looks like you may have some fittings or accessories in your list that don’t have location curves.

Thank you very much @Nick_Boyts, it really did the trick!

But… I thought I have figured out how to select the longest element of every section. But somehow it does not work…

As I showed before it must look like this:

But insteed it looks like this:

Somehow I can’t get it right…

Is it really possible to tag the (pipe) sections like I want to?

GroupByKey isn’t going to work for the longest element. You need to filter by length or sort by length then take the longest element.


Sorry to call on your expertise again but I can’t get this part done either … (This is my first project in dynamo)

Which nodes do I need to determine the length of the elements and which nodes do I need to determine the longest?

This is the last piece of the puzzle I think haha …