public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
// 'Autodesk.Revit.DB.Document.Mirror(ElementSet, Line)' is obsolete:
// Use one of the replace methods in ElementTransformUtils.
//
//Line line = app.Create.NewLine(
// XYZ.Zero, XYZ.BasisX, true ); // 2011
//
//ElementSet els = uidoc.Selection.Elements; // 2011
//
//doc.Mirror( els, line ); // 2011
//Plane plane = new Plane( XYZ.BasisY, XYZ.Zero ); // added in 2012, used until 2016
Plane plane = Plane.CreateByNormalAndOrigin( XYZ.BasisY, XYZ.Zero ); // 2017
ICollection<ElementId> elementIds
= uidoc.Selection.GetElementIds(); // 2012
//ElementTransformUtils.MirrorElements(
// doc, elementIds, plane ); // 2012-2015
using ( Transaction t = new Transaction( doc ) )
{
t.Start( "Mirror Elements" );
ElementTransformUtils.MirrorElements(
doc, elementIds, plane, true ); // 2016
t.Commit();
}
return Result.Succeeded;
}