Reference Pull-Down or Shortcut Menus (Concept)

AutoCAD

 
Reference Pull-Down or Shortcut Menus
Concept Quick Reference
 
 
 

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

The two methods for referencing a pull-down or shortcut menu are relative and absolute. Relative referencing uses the customization group and element ID. Absolute referencing uses the absolute position of a menu item in the menu hierarchy. Relative referencing is recommended because of its dynamic nature, which allows it to function regardless of the current state of a menu.

Relative Referencing of Pull-Down and Shortcut Commands

To reference a pull-down or shortcut menu item based on its customization group and element ID, use 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 CUI file, you can create a partial CUI file with an additional menu item that references the main file. In this manner, partial CUI files and specific base files can work together.

Absolute Referencing of Pull-Down and Shortcut Menu Items

In addition to referencing a menu item, you can activate or deactivate a menu item with the $Pn=xxx syntax. This is the format:

$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 in the POP7 section.

$P7.1=!.

The following example uses the AutoLISP menucmd function to reference a pull-down or shortcut menu item. Because customization files are dynamic (through the loading of partial CUI files), the following syntax won't 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 these forms:

$P@.@= xxx

References the current or most recently chosen command.

$P@. n = xxx

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

AutoLISP Access to Label Status

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.

P n . 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).

P n . 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=~"