Sometimes it is essential in Revit to make sure that no instances of specific families are mirrored in our model. For instance when their direction is recognized in a schedule (eg. door handling). Below I want to show an example of a macro locating every door object in the model that has been mirrored – either by using a mirror command or flip arrows.
First we need access our active document:
Document doc = this.ActiveUIDocument.Document;
UIDocument uiDoc = new UIDocument(doc);
Next we are going to use a very useful Revit API object – Filtered Element Collector. It allows us to query the Revit model for specific objects – for instance belonging to a certain category, like so:
FilteredElementCollector collector = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Doors);
Now we create a variable that is going to contain elements that we will find mirrored:
SelElementSet mirroredElements = SelElementSet.Create();
Then we will iterate through every element collected by the Filtered Element Collector. We are going the check whether the element is a Family Instance – and not element type for example. If it is a Family Instance we can check if it is mirrored:
if(fi.Mirrored) mirrored=true;
Just to be extra sure we are also checking FacingFlipped and HandFlipped properties of the object. If any of those test has a positive result we add the element to our mirroredElements variable.
After running the loop we pass the mirrorElements variable to our active uiDocument. Therefore they become highlighted in the model and can be spotted by user:
uiDoc.Selection.Elements = mirroredElements;
Entire macro code might look like so: