Select Mirrored Doors in Revit

Keeping track of door handedness can be tricky. If you are buying hundreds of doors for a project, listing the wrong type door can be a costly mistake.

One way to handle it is to have different family types for left-hand and right-hand doors.
This method works well, as long as users don’t manually mirror a right-hand family to get something that looks like a left-hand family.
Once this starts to happen, it’s hard to identify which doors have been mirrored (and will be scheduled incorrectly).
My first time dealing with this, I color coded doors by door handedness, and then visually inspected each door. This was very time consuming.

The script below was written with the sole purpose of identifying these mistakes at once with a single click.

You can run it using the RevitPythinShell, or PyRevit.

Screenshot-Button

 

 

 

"""
Select Mirrored Doors

Copyright (c) 2014-2016 Gui Talarico
github.com/gtalarico

TESTED REVIT API:
2015 | 2016

This was written to be used with PyRevit, but can easilly be used as
a standalone script using the IronPythonShell, or
a Dynamo Python component.

--------------------------------------------------------
PyRevit Notice:
Copyright (c) 2014-2016 Ehsan Iran-Nejad
pyRevit: repository at https://github.com/eirannejad/pyRevit

"""

__doc__ = "Selects All Door Instances that have been Mirrored."
__version__ = '0.0.3'

import clr

clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
clr.AddReference("System")

from Autodesk.Revit.UI import TaskDialog
from Autodesk.Revit.DB import FilteredElementCollector
from Autodesk.Revit.DB import BuiltInCategory, ElementId
from System.Collections.Generic import List
# Required for collection

uidoc = __revit__.ActiveUIDocument
doc = __revit__.ActiveUIDocument.Document

try:
 # Try to close PyRevit window
 __window__.Close()
except:
 pass

collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Doors)
doors = collector.ToElements()

mir_doors = []

for door in doors:
 try:
 if door.Mirrored:
 mir_doors.append(door)
 except AttributeError:
 pass # foor Symbols that don't have Mirrored attribute.

TaskDialog.Show("Mirrored Doors", "Mirrored: {} of {} Doors".format(
 len(mir_doors), len(doors)))

# SELECT MIRRORED DOORS | 2015 + 2016 API
selection = uidoc.Selection
collection = List[ElementId]([door.Id for door in mir_doors])
selection.SetElementIds(collection)

# selection = uidoc.Selection.Elements | 2015 API
# for door in mir_doors: | 2015 API
 # selection.Add(door) | 2015 API

 

Select Mirrored Door

 

2 Comments

  1. Jarkko Rauvanlahti

    This looks nice.

    What d you think. Is it possible to make new shared parameter called Mirrored, attach it to doors and modify your python program so that it would add Yes to Mirrored parameter at all Doors that are mirrored? That would bring them visible in schedules and possibly one could change their handednes in schedule using formulas. Would like to acchieve situation that one wouldn’t need to worry about mirroring or not.

    br Jarkko

  2. Hi Jarkko

    That’s a great idea.
    It would 1-2 lines to modify this to _check_ on/off a “Mirrored” project/shared parameter for doors.
    But you would still have to manually run a script/dynamo def to make sure the parameters are “updated”, as they wouldn’t auto-update after you mirror it.

Leave a Reply