[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class cmdMirrorWall : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
Transaction ts = new Transaction(uiDoc.Document, "http://revit.5d6d.com");
ts.Start();
Reference reference = uiDoc.Selection.PickObject(ObjectType.Element, "选择一面墙");
Wall wall = uiDoc.Document.GetElement(reference) as Wall;
MirrorWall(uiDoc.Document, wall);
ts.Commit();
return Result.Succeeded;
}
private void MirrorWall(Document doc, Wall wall)
{
Reference reference = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior).First();
Face face = wall.GetGeometryObjectFromReference(reference) as Face;
UV bboxMin = face.GetBoundingBox().Min;
Plane plane = new Plane(face.ComputeNormal(bboxMin), face.Evaluate(bboxMin).Add(new XYZ(10, 10, 0)));
ElementTransformUtils.MirrorElement(doc, wall.Id, plane);
}
}
[Regeneration(RegenerationOption.Manual)]
public class cmdMirrorWall : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
Transaction ts = new Transaction(uiDoc.Document, "http://revit.5d6d.com");
ts.Start();
Reference reference = uiDoc.Selection.PickObject(ObjectType.Element, "选择一面墙");
Wall wall = uiDoc.Document.GetElement(reference) as Wall;
MirrorWall(uiDoc.Document, wall);
ts.Commit();
return Result.Succeeded;
}
private void MirrorWall(Document doc, Wall wall)
{
Reference reference = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior).First();
Face face = wall.GetGeometryObjectFromReference(reference) as Face;
UV bboxMin = face.GetBoundingBox().Min;
Plane plane = new Plane(face.ComputeNormal(bboxMin), face.Evaluate(bboxMin).Add(new XYZ(10, 10, 0)));
ElementTransformUtils.MirrorElement(doc, wall.Id, plane);
}
}