调用CAD pedit 命令多段线样条曲线化
下面的代码如果注释掉Polyline pline = trans.GetObject(per.ObjectId, OpenMode.ForRead) as Polyline;这句能成功,但是不注释掉这句CAD命令栏提示:错误编辑优化,不理解为什么会这样,向大家请教。#region 多段线样条曲线化
public void pltoSpl()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
try
{
PromptEntityOptions options = new PromptEntityOptions("");
options.Message = "\n请选择多段线";
options.SetRejectMessage("\n所选择实体不是多段线,请重新选择");
options.AddAllowedClass(typeof(Polyline), true);
PromptEntityResult per = ed.GetEntity(options);
Polyline pline = trans.GetObject(per.ObjectId, OpenMode.ForRead) as Polyline;
ResultBuffer rb = new ResultBuffer();
rb.Add(new TypedValue(5005, "_pedit"));
rb.Add(new TypedValue(5006, per.ObjectId));
rb.Add(new TypedValue(5005, "s"));
rb.Add(new TypedValue(5005, ""));
ed.AcedCmd(rb);
}
catch
{
ed.WriteMessage("\n不能转");
}
trans.Commit();
}
}
#endregion
页:
[1]