using app = Autodesk.AutoCAD.ApplicationServices.Application; public static void AddSModelPopupMenu() { //Debug.WriteLine("AddSModelPopupMenu start"); try { //CurrNameSpace_Intialize(); AcadMenuGroups mnus = (AcadMenuGroups)app.MenuGroups; AcadPopupMenus pmnus = mnus.Item(1).Menus; int count =0; foreach (AcadPopupMenu mnu in pmnus) {if (mnu.OnMenuBar==true ) count++;} AcadPopupMenu Menu_SModel=pmnus.Add("&Smodel"); string macro = Convert.ToChar(Keys.Escape).ToString(); //Show main window AcadPopupMenuItem MenuItem_MainForm=Menu_SModel.AddMenuItem(Menu_SModel.Count,"&MainForm",macro+"SMF "); MenuItem_MainForm.HelpString="Show main window"; //Show property window AcadPopupMenuItem MenuItem_PropertyForm=Menu_SModel.AddMenuItem(Menu_SModel.Count,"&ropertyForm",macro+"SPF "); MenuItem_PropertyForm.HelpString="Show property window"; AcadPopupMenuItem MenuItem_PunchE=Menu_SModel.AddMenuItem(Menu_SModel.Count,"Punch&E",macro+"MPE "); MenuItem_PunchE.HelpString="Make PunchE"; AcadPopupMenuItem MenuItem_uc=Menu_SModel.AddMenuItem(Menu_SModel.Count,"Palet&te",macro+"SPS "); MenuItem_PunchE.HelpString="Palelte"; pmnus.InsertMenuInMenuBar("&Smodel",++count); } catch (Exception ex) {smc.ed.WriteMessage (ex.Message);} } 这是增加下拉菜单的代码,希望有帮助! |