我试图为SOLIDWORKS编写一个外接程序,并熟悉这个API。我从添加菜单项开始
public bool ConnectToSW(object ThisSW, int Cookie)
{
this.ThisSW = ThisSW as ISldWorks;
this.Cookie = Cookie;
this.ThisSW.SetAddinCallbackInfo2(0, this, this.Cookie);
SwEventPtr = (SldWorks)this.ThisSW;
this.ThisSW.AddMenuItem5((int)swDocumentTypes_e.swDocPART, this.Cookie, "Item@&File", 0, null, null, "My Menu Item", null);
return true;
}我已经成功地注册了包含上述片段的程序。

但是,当我打开文件菜单时,没有项项。我做错了什么?

发布于 2019-11-22 08:23:29
AddMenuItem5()函数也不适合我(可能是个bug)。您可以使用旧版本,例如AddMenuItem3()
请注意,只有打开部件文档时,菜单项才是可见的。为了使它在其他文档类型中可见,相应地更改第一个参数。使用swDocNone始终显示菜单项。
this.ThisSW.AddMenuItem3((int)swDocumentTypes_e.swDocPART, this.Cookie, "Item@&File", -1, "MyMenuCallback", "MyMenuEnableMethod", "My menu item", "");https://stackoverflow.com/questions/58570590
复制相似问题