最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

menu - Solidworks API AddContextMenu C# - Stack Overflow

programmeradmin2浏览0评论

Having a code which is not working, and cannot get why from SW API documentation.

Trying to add a context menu to a part. Not showing, no matter what I do! ( Also not able to find a callback function, when its clicked (when ill get it).

internal static SldWorks SwApp;
internal static int cookie; 
public bool ConnectToSW(object ThisSW, int Cookie)
{
 SwApp = (SldWorks)ThisSW;
 cookie = Cookie;

 ICommandManager icmd = SwApp.GetCommandManager(cookie);
 ICommandGroup cmdGroup;    
 
 var a = icmd.AddContextMenu(1, "Test");
 a.SelectType = (int)swSelectType_e.swSelEVERYTHING; //tried other options too
 a.AddCommandItem2("Test2", -1, "hint", "tool tip", 1, "Booom", "", 1, (int)(swCommandItemType_e.swMenuItem));
 a.ShowInDocumentType = (int)swDocumentTypes_e.swDocPART;
 a.HasMenu = true;
 //a.Activate(); //cannot be set on contextmenu object. only on CommandGroup.
 //cmdGroup.AddCommandGroup2(); // working. Im able to add both menu and toolbar (but not contextmenu)

 return true;
}

thanks a lot!

发布评论

评论列表(0)

  1. 暂无评论