I'm creating menu groups and sub groups. I add two sub-menus within a group and it doesn't work correctly. The second sub-menu has the same title as the first, even though the code clearly says otherwise. Any suggestions how to fix this?
Code:
mCommandGroup = mCommandManager.CreateCommandGroup(mCommandGroupId++, "Bulk Operations", "", "", -1);
mCommandGroup.Activate(); // activate the top menu
mCommandSubGroupAssy = mCommandManager.CreateCommandGroup(mCommandGroupId++, "Bulk Operations\\Assemblies", "", "", -1); // commands for assemblies
mCommandSubGroupPart = mCommandManager.CreateCommandGroup(mCommandGroupId++, "Bulk Operations\\Parts", "", "", -1); // commands for parts
mCommandSubGroupDwg = mCommandManager.CreateCommandGroup(mCommandGroupId++, "Bulk Operations\\Drawings", "", "", -1); // commands for drawings
// set the group to have both a menu and a toolbar
// you could easily add new parameters and ui items to allow
// the user to dynamically alter these settings
mCommandGroup.HasMenu = true;
mCommandGroup.HasToolbar = true;
mCommandGroup.ShowInDocumentType = documentTypes;
// shows up only in assemblies
documentTypes = (int)swDocTemplateTypes_e.swDocTemplateTypeNONE;
documentTypes |= (int)swDocTemplateTypes_e.swDocTemplateTypeASSEMBLY;
mCommandSubGroupAssy.HasMenu = true;
mCommandSubGroupAssy.HasToolbar = true;
mCommandSubGroupAssy.ShowInDocumentType = documentTypes;
// shows up only in parts
documentTypes = (int)swDocTemplateTypes_e.swDocTemplateTypeNONE;
documentTypes |= (int)swDocTemplateTypes_e.swDocTemplateTypePART;
mCommandSubGroupPart.HasMenu = true;
mCommandSubGroupPart.HasToolbar = true;
mCommandSubGroupPart.ShowInDocumentType = documentTypes;
// shows up only in drawings
documentTypes = (int)swDocTemplateTypes_e.swDocTemplateTypeNONE;
documentTypes |= (int)swDocTemplateTypes_e.swDocTemplateTypeDRAWING;
mCommandSubGroupDwg.HasMenu = true;
mCommandSubGroupDwg.HasToolbar = true;
mCommandSubGroupDwg.ShowInDocumentType = documentTypes;
// Create the menus
int itemType = (int)(swCommandItemType_e.swMenuItem | swCommandItemType_e.swToolbarItem);
int menuID = 1001;
mCommandSubGroupAssy.AddCommandItem2("Save all drawings to PDF", 0, "", "Save all part drawings in this assembly to PDF", 0, "SaveAllPDF_Clicked", "SaveAllPDF_Enable", menuID++, itemType);
mCommandSubGroupAssy.AddCommandItem2("Freeze all parts", 1, "", "Freeze all parts in this assembly", 0, "FreezeAll_Clicked", "FreezeAll_Enable", menuID++, itemType);
mCommandSubGroupAssy.Activate(); // activate the assembly level menu
mCommandSubGroupPart.AddCommandItem2("Freeze Part", 0, "", "Freeze part", 0, "Freeze_Clicked", "Freeze_Enable", menuID++, itemType);
mCommandSubGroupPart.Activate(); // activate the part level menu
mCommandSubGroupDwg.AddCommandItem2("Save drawing to PDF", 0, "", "Save drawing to PDF", 0, "SavePDF_Clicked", "SavePDF_Enable", menuID++, itemType);
mCommandSubGroupDwg.Activate(); // activate the drawing level menu
SolidworksApi macros