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