明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1004|回复: 0

调用CAD pedit 命令多段线样条曲线化

[复制链接]
发表于 2015-8-7 09:06 | 显示全部楼层 |阅读模式
  下面的代码如果注释掉Polyline pline = trans.GetObject(per.ObjectId, OpenMode.ForRead) as Polyline;这句能成功,但是不注释掉这句CAD命令栏提示:错误编辑优化,不理解为什么会这样,向大家请教。

  1.   #region 多段线样条曲线化
  2.         [CommandMethod("pltosp")]
  3.         public void pltoSpl()
  4.         {
  5.             Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
  6.             Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
  7.             using (Transaction trans = db.TransactionManager.StartTransaction())
  8.             {
  9.                 try
  10.                 {
  11.                     PromptEntityOptions options = new PromptEntityOptions("");
  12.                     options.Message = "\n请选择多段线";
  13.                     options.SetRejectMessage("\n所选择实体不是多段线,请重新选择");
  14.                     options.AddAllowedClass(typeof(Polyline), true);
  15.                     PromptEntityResult per = ed.GetEntity(options);
  16.                     Polyline pline = trans.GetObject(per.ObjectId, OpenMode.ForRead) as Polyline;
  17.                     ResultBuffer rb = new ResultBuffer();
  18.                     rb.Add(new TypedValue(5005, "_pedit"));
  19.                     rb.Add(new TypedValue(5006, per.ObjectId));
  20.                     rb.Add(new TypedValue(5005, "s"));
  21.                     rb.Add(new TypedValue(5005, ""));
  22.                     ed.AcedCmd(rb);
  23.                 }
  24.                 catch
  25.                 {
  26.                     ed.WriteMessage("\n不能转");
  27.                 }
  28.                 trans.Commit();
  29.             }
  30.         }
  31.         #endregion

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-24 23:54 , Processed in 0.157340 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表