Author Topic: Testing if a menu is already loaded  (Read 183 times)

0 Members and 1 Guest are viewing this topic.

ajtruckle

  • Mosquito
  • Posts: 5
Testing if a menu is already loaded
« on: January 31, 2021, 08:27:14 AM »
In BricsCAD all you need to do is:

Code: [Select]
Application.IsMenuGroupLoaded("xxx")
But the IsMenuGroupLoaded method is not available for AutoCAD nor ZWCAD.

At the moment I am using COM for the other two CAD application. Eg:

Code: [Select]
var AXAPP = (_AxApp.AcadApplication)_AcAp.Application.AcadApplication; // COM
for (int iMenuGroup = 0; iMenuGroup < AXAPP.MenuGroups.Count - 0; iMenuGroup++)
{
    if (AXAPP.MenuGroups.Item(iMenuGroup).Name == "xxx")
    {
        _AcAp.Application.ShowAlertDialog("The ribbon is already loaded.");
        bLoadCUI = false;
        break;
    }
}

Does AutoCAD and ZWCAD have a simpler solution like IsMenuGroupLoaded?

Jeff_M

  • King Gator
  • Posts: 3998
  • C3D user & customizer
Re: Testing if a menu is already loaded
« Reply #1 on: January 31, 2021, 02:00:24 PM »
You can simplify it a bit by not needing to reference the COM libraries:
Code - C#: [Select]
  1. dynamic menugroups = _AcAp.Application.MenuGroups
  2. for (int iMenuGroup = 0; iMenuGroup < menugroups.Count; iMenuGroup++)
  3. {
  4.     if (menugroups.Item(iMenuGroup).Name == "xxx")
  5.     {
  6.         _AcAp.Application.ShowAlertDialog("The ribbon is already loaded.");
  7.         bLoadCUI = false;
  8.         break;
  9.     }
  10. }