马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
 - private string keyWord;
- [CommandMethod("myTest")]
- public void Test()
- {
- Editor ed = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument.Editor;
- keyWord = "LIne";
- PromptSelectionOptions opt = new PromptSelectionOptions();
- opt.SetKeywords("[CIrcle/LIne/POlyline]", "CIrcle LIne POlyline");
- opt.MessageForAdding = "\nSelect objects or " + opt.Keywords.GetDisplayString(true);
- opt.KeywordInput += onKeywordInput;
- ed.SelectionAdded += onSelectionAdded;
- PromptSelectionResult psr = ed.GetSelection(opt);
- ed.SelectionAdded -= onSelectionAdded;
- if (psr.Status == PromptStatus.OK)
- ed.SetImpliedSelection(psr.Value);
- }
- private void onKeywordInput(object sender, SelectionTextInputEventArgs e)
- {
- this.keyWord = e.Input;
- }
- private void onSelectionAdded(object sender, SelectionAddedEventArgs e)
- {
- RXClass rxc;
- switch (this.keyWord)
- {
- case "POlyline":
- rxc = RXClass.GetClass(typeof(Polyline));
- break;
- case "CIrcle":
- rxc = RXClass.GetClass(typeof(Circle));
- break;
- default:
- rxc = RXClass.GetClass(typeof(Line));
- break;
- }
- ObjectId[] ids = e.AddedObjects.GetObjectIds();
- for (int i = 0; i < ids.Length; i++)
- {
- if (ids[i].ObjectClass != rxc)
- {
- e.Remove(i);
- }
- }
- }
|