using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI.Selection;
namespace ClassLibrary1
{
[Autodesk.Revit.Attributes.Transaction(TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(RegenerationOption.Manual)]
public class GetElement : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
Selection selection = uidoc.Selection;
#region 元素的移动
using (Transaction ts = new Transaction(doc))
{
ts.Start("Move Element");
Reference reff = selection.PickObject(ObjectType.Element, " 选择一个墙体!");
Element elem = doc.GetElement(reff);
Wall wall = elem as Wall;
//get location curve
LocationCurve lc = wall.Location as LocationCurve;
XYZ p1 = new XYZ(100, 100, 0);
XYZ p2 = new XYZ(100, 0, 0);
Line newWall = Line.CreateBound(p1, p2);
//把墙的位置线换成新的线
lc.Curve = newWall;
ts.Commit();
}
#endregion
return Result.Succeeded;
}
}
}