58 lines
1.9 KiB
C#
58 lines
1.9 KiB
C#
using Autodesk.Revit.Attributes;
|
|
using Autodesk.Revit.DB;
|
|
using Autodesk.Revit.UI;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace HYJig
|
|
{
|
|
[Regeneration(0)]
|
|
[Transaction(TransactionMode.Manual)]
|
|
public class JigArc : IExternalCommand
|
|
{
|
|
public Result Execute(ExternalCommandData cmdData, ref string message, ElementSet elements)
|
|
{
|
|
UIDocument activeUIDocument = cmdData.Application.ActiveUIDocument;
|
|
ViewAssist.ViewValidating(activeUIDocument.Document, activeUIDocument.ActiveView);
|
|
XArcJig xarcJig = new XArcJig(activeUIDocument);
|
|
XYZ xyz = xarcJig.PickCenterPoint("请确定圆弧中心点:");
|
|
Result result;
|
|
if (xyz == null)
|
|
{
|
|
xarcJig.Dispose();
|
|
result = 0;
|
|
}
|
|
else
|
|
{
|
|
XYZ xyz2 = xarcJig.PickStartPoint(xyz, "请确定圆弧起点:");
|
|
if (xyz2 == null)
|
|
{
|
|
xarcJig.Dispose();
|
|
result = 0;
|
|
}
|
|
else
|
|
{
|
|
XYZ xyz3 = xarcJig.PickEndPoint(xyz, xyz2, "请确定圆弧终点:");
|
|
if (xyz3 == null)
|
|
{
|
|
xarcJig.Dispose();
|
|
result = 0;
|
|
}
|
|
else
|
|
{
|
|
Transaction transaction = new Transaction(activeUIDocument.Document);
|
|
transaction.Start("CreateCurve");
|
|
List<Curve> list = xarcJig.CreateCurves();
|
|
activeUIDocument.Document.Create.NewDetailCurve(activeUIDocument.ActiveView, list[0]);
|
|
transaction.Commit();
|
|
xarcJig.Dispose();
|
|
result = 0;
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
}
|