About Referencing a Pull-Down or Shortcut Menu

Using a method similar to that used to activate submenus, you can activate or deactivate another pull-down or shortcut menu. This is called menu referencing.

Pull-down or shortcut menus can be referenced using two different methods: relative and absolute. Absolute referencing uses the absolute position of a menu item in the menu hierarchy. Relative referencing uses the customization group name and element ID. Relative referencing is recommended because of its dynamic nature, but it is not available in AutoCAD LT.

Absolute Referencing

In addition to referencing a menu item, you can activate or deactivate a menu item with the following syntax:

$Pn.i=xxx

The $ loads a menu section; Pn specifies the active menu section (0 through 16 are valid values); i specifies the menu item number; and xxx (if present), specifies a string of grayed out or marked characters.

Using the $Pn=xxx syntax, the following example adds a check mark to item 1 on the menu with the POP7 alias.

$P7.1=!.

The following example, in AutoCAD, uses the AutoLISP menucmd function to reference a pull-down or shortcut menu item. Because customization files are dynamic (through the loading of partial CUIx files), the following syntax will not work in all cases.

(menucmd "P1.2=~")

This syntax relies on the location of the menu item and does not work if a new item is inserted before POP1 by the CUILOAD command.

Menu item numbering is consecutive regardless of the hierarchy of the menu.

To make it easy for an item to address itself regardless of its location in the menu hierarchy, use the following:

$P@.@=xxx

References the current or most recently chosen command.

$P@.n=xxx

References item n in the current or most recently chosen menu.

Relative Referencing (Not available AutoCAD LT)

You can reference a pull-down or shortcut menu item based on its customization group and element ID with the AutoLISP menucmd function. The following syntax references a menu item based on its element ID.

(menucmd "Gcustomizationgroup.element_id=value")

The following example uses the relative referencing syntax to disable the menu item ID_Line that is stored in the ACAD customization group. It works regardless of the menu item's location in the menu.

(menucmd "GACAD.ID_Line=~")

If you know what is contained in the main customization (CUIx) file, you can create a partial customization (CUIx) file with an additional menu item that references the main CUIx file. In this manner, partial CUIx files and specific base customization files can work together.

AutoLISP Access to Label Status (Not available AutoCAD LT)

The AutoLISP menucmd function accepts $Pn=xxx command strings but without the leading $. For these functions, the xxx portion of the command string can have special values.

Pn.i=?

Returns the current disabled and marked status for the specified item as a string (for example, ~ for a disabled item, !. for an item with a check mark, and "" for an item that is neither grayed out nor marked).

Pn.i=#?

Returns the same type of string as described for Pn.i=?, but with the Pn.i= prefix. This is useful in conjunction with the @ forms, because the actual menu and item number are returned.

For example, if the fifth item in the POP6 section is disabled, the following menucmd code returns the following string values.

(menucmd "P6.5=?")     returns  "~" 
(menucmd "P6.5=#?")    returns  "P6.5=~"