48 lines
1.7 KiB
C#
48 lines
1.7 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 JigCircle : IExternalCommand
|
|
{
|
|
public Result Execute(ExternalCommandData cmdData, ref string message, ElementSet elements)
|
|
{
|
|
UIDocument activeUIDocument = cmdData.Application.ActiveUIDocument;
|
|
ViewAssist.ViewValidating(activeUIDocument.Document, activeUIDocument.ActiveView);
|
|
XCircleJig xcircleJig = new XCircleJig(activeUIDocument);
|
|
XYZ xyz = xcircleJig.PickCenterPoint("请确定圆中心点:");
|
|
Result result;
|
|
if (xyz == null)
|
|
{
|
|
xcircleJig.Dispose();
|
|
result = 0;
|
|
}
|
|
else
|
|
{
|
|
double num = xcircleJig.PickCircleRadius(xyz, "请确定圆上一点:");
|
|
if (num == 0.0)
|
|
{
|
|
xcircleJig.Dispose();
|
|
result = 0;
|
|
}
|
|
else
|
|
{
|
|
Transaction transaction = new Transaction(activeUIDocument.Document);
|
|
transaction.Start("CreateCurve");
|
|
Arc arc = Arc.Create(xyz, num, 0.0, 6.2831853071795862, activeUIDocument.ActiveView.RightDirection, activeUIDocument.ActiveView.UpDirection);
|
|
activeUIDocument.Document.Create.NewDetailCurve(activeUIDocument.ActiveView, arc);
|
|
transaction.Commit();
|
|
xcircleJig.Dispose();
|
|
result = 0;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
}
|