using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
namespace Test
{
public class CircularArc3dTest
{
[CommandMethod("CircularArcTest")]
public void RunTest1()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptPointResult
pt1Res = ed.GetPoint("\nSelect first point: "),
pt2Res = ed.GetPoint("\nSelect second point: "),
pt3Res = ed.GetPoint("\nSelect third point: ");
if (pt1Res.Status == PromptStatus.OK && pt2Res.Status == PromptStatus.OK && pt3Res.Status == PromptStatus.OK)
{
using (CircularArc3d arc = new CircularArc3d(pt1Res.Value, pt2Res.Value, pt3Res.Value))
{
ed.WriteMessage
("\nCircularArc3d. StartAngle: {0}, EndAngle: {1}",
arc.StartAngle.ToString("0.000"),
arc.EndAngle.ToString("0.000"));
}
}
}
[CommandMethod("ArcEntityTest")]
public void RunTest2()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptEntityOptions entOpt = new PromptEntityOptions("\nSelect arc: ");
entOpt.SetRejectMessage("This is not arc!");
entOpt.AddAllowedClass(typeof(Arc), true);
PromptEntityResult entRes = ed.GetEntity(entOpt);
if (entRes.Status == PromptStatus.OK)
{
using (Transaction tr = ed.Document.Database.TransactionManager.StartTransaction())
{
Arc arc = tr.GetObject(entRes.ObjectId, OpenMode.ForRead, false, true) as Arc;
if (arc != null)
{
ed.WriteMessage
("\nArc entity. StartAngle: {0}, EndAngle: {1}",
arc.StartAngle.ToString("0.000"),
arc.EndAngle.ToString("0.000"));
}
tr.Commit();
}
}
}
}
}