/*
[轉貼]Revit API中長度單位都是英呎
Revit API中長度單位都是英呎
1英吋(in) = 2.54(cm) = 0.0000254(mm)
*/
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class GetEndsPt : IExternalCommand
{
public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
try
{
Document doc = commandData.Application.ActiveUIDocument.Document;
Selection sel = commandData.Application.ActiveUIDocument.Selection;
Reference ref1 = sel.PickObject(ObjectType.Element, "請選擇一個模型線");
ModelLine dbline = doc.GetElement(ref1) as ModelLine;
Curve cure = dbline.GeometryCurve;
XYZ ptStart = cure.get_EndPoint(0);
XYZ ptEnd = cure.get_EndPoint(1);
string slineinfo = "line Info: ";
slineinfo += string.Format("\n開始點xyz:({0:F3},{1:F3},{2:F3})", ptStart.X, ptStart.Y, ptStart.Z);
slineinfo += string.Format("\n結束點xyz:({0:F3},{1:F3},{2:F3})", ptEnd.X, ptEnd.Y, ptEnd.Z);
slineinfo += "\n線長:" + cure.Length;
TaskDialog.Show("Get Model Line length", slineinfo);
}
catch(Exception ex)
{
message = ex.Message;
return Result.Failed;
}
return Result.Succeeded;
}
}
全站熱搜
留言列表