Guys, please!! anyone! dying here…
Trying to make a simple ContextMenu in a part.
cannot get it done. googled any combination. spent hours trying diff approaches. NOTHING!!
Im sure i’m missing a very small details here. but i cannot get which one (((
please adivce:
the code is pretty simple (for a test)
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 conntextmenu object. only on CommanndGroup.
//cmdGroup.AddCommandGroup2(); // working. Im able to add both menu and toolbar (but not contextmenu)
return true;
}
Thanks!!!
If i'm already asking, how do I add ca callback to contextMenu? thanks agian
– aleXelause SolidDNA to build SOLIDWORKS add-ins https://github.com/cad-booster/solidworks-api
– liuningHey, thanks, but I dont want to use a framework. Checked both SW frameworks and didnt find an answer to my question.
– aleXela