Gets the menu of macro commands.

syntaxSyntax:
DlxApp.GetMenu(menuId)

Parameters

Parameter Description
menuId Identifies the menu. Specify one of the following values:
Value Meaning
DlxApp.MENU_APP The macro menu present in the application ribbon when there are no documents open.
DlxApp.MENU_DWG The macro menu in the Graphics ribbon.
DlxApp.MENU_SCH The macro menu in the Schematic ribbon.
DlxApp.MENU_PCB The macro menu in the PCB ribbon.
DlxApp.MENU_LIB The macro menu in the Library ribbon.
DlxApp.MENU_OPERATION The macro menu in the Operations ribbon.
DlxApp.MENU_LIBRARY The macro menu in the Device Library ribbon.

Return Value

Returns the object DlxMenu corresponding to the menu. Call the IsValid() method to determine if the object is valid.

Example

  Copy codeCopy code
function OnMenu()
{
  var menu = DlxApp.GetMenu(DlxApp.MENU_DWG);
  if (menu.IsValid())
  {
    var subMenu = menu.AddMenu("My Macro");
    subMenu.AddCommand("command10", 10, "Description of command 10\nCmd10");
    subMenu.AddCommand("command20", 20, "Description of command 20\nCmd20");
    subMenu.AddLabel("Label");
    subMenu.AddCommand("command30", 30, "Description of command 30\nCmd30");
    subMenu.AddCommand("command40", 40, "Description of command 40\nCmd40");
    subMenu.AddSeparator();
    subMenu.AddCommand("command50", 50, "Description of command 50\nCmd50");
    subMenu.AddCommand("command60", 60, "Description of command 60\nCmd60");
  }
}

function OnMenuUpdateCommand(cmd)
{
  switch (cmd.GetCommandId())
  {
  case 10:
    cmd.Enable(true);
    break;
  case 20:
    cmd.Enable(true);
    break;
  case 30:
    cmd.Enable(true);
    break;
  case 40:
    cmd.Enable(true);
    cmd.SetCheck(true);
    break;
  case 50:
   cmd.Enable(false);
    break;
  case 60:
    cmd.Enable(true);
    break;
  }
}

function OnMenuCommand(cmdId)
{
  switch (cmdId)
  {
    case 10:
      DlxApp.Printf("CmdId 10");
      break;
    case 20:
      DlxApp.Printf("CmdId 20");
      break;
    case 30:
      DlxApp.Printf("CmdId 30");
      break;
    case 40:
      DlxApp.Printf("CmdId 40");
      break;
    case 50:
      DlxApp.Printf("CmdId 50");
      break;
    case 60:
      DlxApp.Printf("CmdId 60");
      break;
  }
}

See also