欢迎加我的QQ群:193522571,一起来讨论、交流!

Getselection能不能接受keyword?

这个玩意绝对是个坑,CAD对Getselection的支持并不充分,需要通过keywordinput事件来弄,比较麻烦,而且很容易出问题。

所以我的做法是,不使用,哈哈!

下面这个是kean的代码:

复制代码
    [CommandMethod("SELKW")]

    public void GetSelectionWithKeywords()
    {
      Document doc = AcadApp.DocumentManager.MdiActiveDocument;
      Editor ed = doc.Editor;
      PromptSelectionOptions pso = new PromptSelectionOptions();
      pso.Keywords.Add("FIrst");
      pso.Keywords.Add("Second");
      string kws = pso.Keywords.GetDisplayString(true);
      pso.MessageForAdding = "\nAdd objects to selection or " + kws;
      pso.MessageForRemoval = "\nRemove objects from selection or " + kws;
      pso.KeywordInput +=
        delegate (object sender, SelectionTextInputEventArgs e)
        {
          ed.WriteMessage("\nKeyword entered: {0}", e.Input);
        };
      PromptSelectionResult psr = ed.GetSelection(pso);
      if (psr.Status == PromptStatus.OK)
      {
        ed.WriteMessage("\n{0} object{1} selected.",
          psr.Value.Count,
          psr.Value.Count == 1 ? "" : "s"
        );
      }
    }
复制代码

 

posted @   swtool  阅读(43)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 字符编码:从基础到乱码解决
欢迎加我的QQ群:193522571,一起来讨论、交流!
点击右上角即可分享
微信分享提示