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" ); } }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 字符编码:从基础到乱码解决