public void PprArc() { //准备工作 Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; Transaction trans = db.TransactionManager.StartTransaction(); BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord btr = trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; PromptPointOptions ppo = new PromptPointOptions(""); PromptPointResult ppr; Point3d temp = new Point3d(); Point2d p1, p2; //获取两个点 ppo.Message = "\n请输入第一个点:"; do { ppr = ed.GetPoint(ppo); temp = ppr.Value; p1 = new Point2d(temp.X, temp.Y); } while (ppr.Status != PromptStatus.OK); ppo.Message = "\n请输入第二个点:"; do { ppr = ed.GetPoint(ppo); temp = ppr.Value; p2 = new Point2d(temp.X, temp.Y); } while (ppr.Status != PromptStatus.OK); double L = p1.GetDistanceTo(p2); double R = 0; //获取半径 do {//避免出现半径比弦长一半还小的情况出现 PromptDoubleOptions pdo = new PromptDoubleOptions("\n最后,请输入半径:"); PromptDoubleResult pdr = ed.GetDouble(pdo); if (pdr.Status == PromptStatus.OK) { R = pdr.Value; } } while (R < L / 2); double H = R - Math.Sqrt(R * R - L * L / 4); Polyline poly = new Polyline(); poly.AddVertexAt(0, p1, 2 * H / L, 0, 0); poly.AddVertexAt(1, p2, 0, 0, 0); btr.AppendEntity(poly); trans.AddNewlyCreatedDBObject(poly, true); trans.Commit(); trans.Dispose(); }