Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\ZWSOFT\ZWCADM\2018\zh-CN\Applications\AutoCADADDIN]
"DESCRIPTION"=""
"LOADCTRLS"=dword:0000000d
"LOADER"="D:\\Users\\ZWCAD\\AutoCADADDIN.dll"
"MANAGED"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\ZWSOFT\ZWCADM\2018\zh-CN\Applications\AutoCADADDIN\Commands]
"ADDMYPALETTESET"="ADDMYPALETTESET"
"OPENMYHOME"="OPENMYHOME"
"COSEMYHOME"="COSEMYHOME"
"LOGINTC"="LOGINTC"
[HKEY_LOCAL_MACHINE\SOFTWARE\ZWSOFT\ZWCADM\2018\zh-CN\Applications\AutoCADADDIN\Groups]
"AutoCADADDIN"="AutoCADADDIN"
[CommandMethod("caidan")]
public void ShowJingDianMenu()
{
try
{
IAcadApplication app = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication as AcadApplication;
if (app == null) return;
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
if (app.MenuGroups == null || app.MenuGroups.Item(0) == null) return;
AcadMenuGroups acadMenuGroups = app.MenuGroups;
int index = 0;
foreach (AcadMenuGroup item in acadMenuGroups)
{
string name = item.Name;
//name.ToLower() == "3dtool_menugroup"
if ( name.ToLower() == "amacad")
break;
index++;
}
for (int i = 0; i < app.MenuGroups.Item(index).Menus.Count; i++)
{
if (app.MenuGroups.Item(index).Menus.Item(i).Name == "3DTool")
{
//app.MenuGroups.Item(index).Menus.Item(i).RemoveFromMenuBar();
ed.WriteMessage("3DTool已存在菜单组!");
return;
}
}
//添加根菜单
AcadPopupMenu pmParnet = app.MenuGroups.Item(index).Menus.Add("3DTool");
int countmenubar = app.MenuBar.Count;
//多级 AcadPopupMenu
//AcadPopupMenu pm = pmParnet.AddSubMenu(pmParnet.Count + 1, "绘制模型");
//AcadPopupMenuItem pmi0 = pm.AddMenuItem(pm.Count + 1, "文件 ", "OPEN1\n"); //第一个参数是在菜单项中的位置(第几项),第二个参数是显示的名称,第三个参数是点击之后执行的命令
//AcadPopupMenuItem pmi1 = pm.AddMenuItem(pm.Count + 1, "模版 ", "OPEN2\n");
//单级 AcadPopupMenuItem
pmParnet.AddMenuItem(pmParnet.Count + 1, "绘制模型", "_CON ");
pmParnet.AddSeparator(pmParnet.Count + 1);
pmParnet.AddMenuItem(pmParnet.Count + 1, "导出设备清单", "_ETOE ");
pmParnet.AddSeparator(pmParnet.Count + 1);
pmParnet.AddMenuItem(pmParnet.Count + 1, "修改模型", "_MDC ");
pmParnet.AddSeparator(pmParnet.Count + 1);
pmParnet.AddMenuItem(pmParnet.Count + 1, "修改编号", "_GAT ");
pmParnet.AddSeparator(pmParnet.Count + 1);
pmParnet.AddMenuItem(pmParnet.Count + 1, "输出GA图", "_GAT ");
pmParnet.AddSeparator(pmParnet.Count + 1);
pmParnet.AddMenuItem(pmParnet.Count + 1, "导出BOM清单", "_EBOM ");
pmParnet.AddSeparator(pmParnet.Count + 1);
pmParnet.AddMenuItem(pmParnet.Count + 1, "镜像和改属性", "cusmirror ");
//将创建的菜单加入到CAD的菜单中
pmParnet.InsertInMenuBar(countmenubar + 1);
ed.WriteMessage("3DTool工具条生成完成!");
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
}
-----------------------------------
©著作权归作者所有:来自51CTO博客作者CAD开发_李盼的原创作品,请联系作者获取转载授权,否则将追究法律责任
C# 开发cad 添加菜单栏下拉子菜单
https://blog.51cto.com/u_15825922/7022037