TheSwamp

Code Red => .NET => Topic started by: ajtruckle on January 31, 2021, 08:27:14 AM

Title: Testing if a menu is already loaded
Post by: ajtruckle 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?
Title: Re: Testing if a menu is already loaded
Post by: Jeff_M 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. }