using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LOOKupidandlocation
{
[Transaction(TransactionMode.Manual)]
public class Command : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Document revitDoc = commandData.Application.ActiveUIDocument.Document; //取得文档
UIDocument uidoc = commandData.Application.ActiveUIDocument;
UIApplication uiApp = commandData.Application;
Autodesk.Revit.ApplicationServices.Application revitApp = commandData.Application.Application; //取得应用程序
Selection sel = uidoc.Selection;
Reference reference = sel.PickObject(ObjectType.Element);
Element element = revitDoc.GetElement(reference);
Wall wall = element as Wall;
if (null != wall)
{
Location location = wall.Location;
LocationCurve locationCurve= location as LocationCurve;
if (locationCurve !=null )
{
Curve curve = locationCurve.Curve;
MessageBox.Show((curve.Length).ToString());
}
}
return Result.Succeeded;
}
}
}