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!