Select all Untagged Doors in ActiveView

Here is a simple Snippet to get All Doors and DoorTags in the ActiveView. It will also check which doors are not tagged, and display their ElementIds.

Code Snippet

#⬇️ Imports
from Autodesk.Revit.DB import *

#📦Variables
doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
active_view = doc.ActiveView

#👉 Collect Doors and Tags in View
all_doors_in_view = FilteredElementCollector(doc, active_view.Id)\
                            .OfCategory(BuiltInCategory.OST_Doors)\
                            .WhereElementIsNotElementType()\
                            .ToElements()
all_tags_in_view  = FilteredElementCollector(doc, active_view.Id)\
                     .OfCategory(BuiltInCategory.OST_DoorTags)\
                     .WhereElementIsNotElementType()\
                     .ToElements()
                     

#🔎 Check Tagged Doors
tagged_door_ids = [tag.GetTaggedLocalElements()[0].Id for tag in all_tags_in_view]
untagged_doors  = [door.Id for door in all_doors_in_view if door.Id not in tagged_door_ids]

#👀 Preview Results
print('Doors in View   : {}'.format(len(list(all_doors_in_view))))
print('DoorTags in View: {}'.format(len(list(all_tags_in_view))))
print('Tagged Doors    : {}'.format(len(tagged_door_ids)))
print('Untagged Doors  : {}'.format(len(untagged_doors)))

#🪄 Select Untagged Doors in View
import clr
clr.AddReference('System')
from System.Collections.Generic import List
uidoc.Selection.SetElementIds(List[ElementId](untagged_doors))

⌨️ Happy Coding!
Erik Frits