Struggling with automatic door tags

Hello, I’ve been working on a script for renumbering the mark of a door tag by room number. The naming convention I am trying to use is N or E to indicate new or existing, followed by the door number, followed by A, B, C etc depending on how many doors are in the room. E101B would be the second existing door in room 101.

I have the prefix and door number working properly, but I am struggling with counting the number of doors in the room and converting it to the A, B, C sequence. Sometimes the count is wrong in my current script, and I’d also like to keep the count separate for new and existing doors. If I had a new and existing door in room 105, I’d like to output N105A and E105A rather than N105A E105B.

I’ve attached an image of the graph for reference, thanks.

The easiest way to handle this is to assign room number and phase first. Then you can group by value (ex: N105, E105) to get the sets of doors that need to be counted together. Then you just get counts for those sublists and create each sequence based on count.

I appreciate the help! I think I figured out how to produce the right labels by counting the sublists as seen in the final watch node, but now the labels are not associating to the correct doors. Not sure if this is a dumb question, but how would I re-sort the list?


You sorted the list of values but not the elements. Don’t sort the list unless you have to. If you have to, then be sure to use SortByKey to sort the values and the elements.

After combining the values (codeblock: a+b), you can just use GroupByKey to group all the doors based on their similar values. Then you can count the doors in each group to create the sequence for each group.

I am still confused by how to sort the elements by the sorted keys. Are you suggesting I sort before codeblock a+b?

SortByKey sorts a list of inputs based on the supplied keys. The keys should be the combined door values and the list should be the doors. This would sort the door elements based on their key value.

I tried to follow your suggestion, but the elements still are not sorting correctly. I have the door elements as my list, and the sorted list of door numbers as the key. Were you referring to something else? Would it be helpful to upload the script?

Your description doesn’t match your image. It should look like this.


Any grouping or sorting after that should follow the same rule of applying the group/sort to the doors.

Thanks, that worked. I misunderstood what you were referring to by combined door values. Here is the final solution for anyone else facing the same problem.

I have edited the solution to create tags of my work template. Every door tag is in the form as Internal door = G.31 External door = G.01 , where G means ground floor level ( floor level on which door is placed) 01 / 31 sequence for door numbers.
I am not able to connect the lists in the form of my template. As the lists are not taking internal/ external filtering. What should I do? Using REVIT 2022
DYNAMO core 2.10.1.3976
Dynamo revit 2.10.1.4002

With the above question, here is what I tried to do