The ElementTransformUtils class provides two static methods to mirror one or more elements in the project.
Table 21: Mirror Methods
Member |
Description |
MirrorElement(Document, ElementId, Plane) |
Mirror one element about a geometric plane. |
MirrorElements(Document, ICollection<ElementId>, Plane, Boolean) |
Mirror several elements about a geometric plane. Can be performed on original geometry or a copy. |
After performing the mirror operation, you can access the new elements from the Selection ElementSet.
ElementTransformUtils.CanMirrorElement() and ElementTransformUtils.CanMirrorElements() can be used to determine if one or more elements can be mirrored prior to attempting to mirror an element.
The following code illustrates how to mirror a wall using a plane calculated based on a side face of the wall.
Code Region 10-8: Mirroring a wall |
public void MirrorWall(Autodesk.Revit.DB.Document document, Wall wall) { Reference reference = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior).First(); // get one of the wall's major side faces Face face = wall.GetGeometryObjectFromReference(reference) as Face; UV bboxMin = face.GetBoundingBox().Min; // create a plane based on this side face with an offset of 10 in the X & Y directions Plane plane = new Plane(face.ComputeNormal(bboxMin), face.Evaluate(bboxMin).Add(new XYZ(10, 10, 0))); ElementTransformUtils.MirrorElement(document, wall.Id, plane); } |
Every FamilyInstance has a Mirrored property. It indicates whether a FamilyInstance (for example a column) is mirrored.