34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
|
|
using Autodesk.Revit.Attributes;
|
|||
|
|
using Autodesk.Revit.DB;
|
|||
|
|
using Autodesk.Revit.UI;
|
|||
|
|
|
|||
|
|
using System;
|
|||
|
|
|
|||
|
|
namespace HYJig
|
|||
|
|
{
|
|||
|
|
[Regeneration(0)]
|
|||
|
|
[Transaction(TransactionMode.Manual)]
|
|||
|
|
public class PickPoint : IExternalCommand
|
|||
|
|
{
|
|||
|
|
public Result Execute(ExternalCommandData cmdData, ref string message, ElementSet elements)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
UIDocument activeUIDocument = cmdData.Application.ActiveUIDocument;
|
|||
|
|
ViewAssist.ViewValidating(activeUIDocument.Document, activeUIDocument.ActiveView);
|
|||
|
|
XYZ xyz = activeUIDocument.Selection.PickPoint("请选择第一点:");
|
|||
|
|
XYZ xyz2 = activeUIDocument.Selection.PickPoint(xyz, activeUIDocument, "请选择第二点:");
|
|||
|
|
Transaction transaction = new Transaction(activeUIDocument.Document);
|
|||
|
|
transaction.Start("CreateCurve");
|
|||
|
|
Line line = Line.CreateBound(xyz, xyz2);
|
|||
|
|
activeUIDocument.Document.Create.NewDetailCurve(activeUIDocument.ActiveView, line);
|
|||
|
|
transaction.Commit();
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|