Tag rooms in multiple views

So recently in the comments below post on tagging through multiple views some questions have been asked about doing same for rooms. For some reason room tags in Revit are a different kind of element than other tags.

Anyways, I have tried to give an answer in the comments section but it didn’t seem to work. So I have tried one more time and now it works! (at least in Revit 2019). Here is the Python code:

import clr

from Autodesk.Revit.DB import *

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

doc = DocumentManager.Instance.CurrentDBDocument

#The inputs to this node will be stored as a list in the IN variables.
views = UnwrapElement(IN[0])
tag = UnwrapElement(IN[1])

output = []


for v in views:
  if not v.IsTemplate:
    elementCollector = FilteredElementCollector(doc,v.Id).OfCategory(BuiltInCategory.OST_Rooms)
    tagCollector = FilteredElementCollector(doc,v.Id).OfClass(SpatialElementTag)
    notTagged = []
    for r in elementCollector:
      tagged = False
      for t in tagCollector:
        if t.Room==r:
          tagged = True
      if not tagged:
    for r in notTagged:
      rId = LinkElementId(r.Id)
      t = doc.Create.NewRoomTag(rId, UV(r.Location.Point.X,r.Location.Point.Y), v.Id)
#Assign your output to the OUT variable.
OUT = output

The main difference is of course doc.Create.NewRoomTag function, which is room tag specific. One tricky part – as an argument you have to pass LinkElementId of the room – regardless if it is located in the current or linked model. The conversion from regular element Id is done through:

rId = LinkElementId(r.Id)

You can also download a .dyn file below. For simplicity I have used some archilab nodes to collect the views – but it is not necessary for the script to work.

If Python is not your thing you can always try our Onion Nodes. Element.FindNotTagged node can help you achieve same result easily.

Posts created 45

3 thoughts on “Tag rooms in multiple views

  1. I am trying to modify this so that it includes rooms in a linked model. How would I go about doing this?

    1. You have to add another input to the python node – linkInstance.
      Then you can get a reference to the linkedDoc like so:

      linkInstance = UnwrapElement(IN[2])
      linkedDoc = linkInstance.GetLinkDocument()

      To check if the room is tagged or not you have to use not a ‘Room’ property of the tag element but ‘TaggedRoomId’.
      You can get linked room id like this:

      rIds = [LinkElementId(linkInstance.Id,x.Id) for x in elementCollector]

      and then you can compare with tag’s property:

      if t.TaggedRoomId==rId:
      tagged = True

      You will also need to use above ids in the tag create function.

      If your linked model is moved in the host model then you will also have to transform location so it points at the right spot.

  2. Pingback: My Homepage

Leave a Reply

Your email address will not be published.

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top