menucmd

AutoCad AutoLISP Functions

 
menucmd
 
 
 

Issues menu commands, or sets and retrieves menu item status

(menucmd string) 

The menucmd function can switch between subpages in an AutoCAD menu. This function can also force the display of menus. This allows AutoLISP programs to use image tile menus and to display other menus from which the user can make selections. AutoLISP programs can also enable, disable, and place marks in menu items.

Arguments

string

A string that specifies a menu area and the value to assign to that menu area. The string argument has the following parameters:

"menu_area=value"

The allowed values of menu_area, shown in the following list, are the same as they are in menu file submenu references. For more information, see “Overview of Pull-Down and Shortcut Menus” in the Customization Guide.

B1-B4 BUTTONS menus 1 through 4.

A1-A4 AUX menus 1 through 4.

P0-P16 Pull-down (POP) menus 0 through 16.

I Image tile menus.

S SCREEN menu.

T1-T4 TABLET menus 1 through 4.

M DIESEL string expressions.

Gmenugroup.nametag A menugroup and name tag.

Return Values

nil

Examples

The following code displays the image tile menu MOREICONS:

(menucmd "I=moreicons")       Loads
the MOREICONS image tile menu
(menucmd "I=*")               Displays
the menu

The following code checks the status of the third menu item in the pull-down menu POP11. If the menu item is currently enabled, the menucmd function disables it.

(setq s (menucmd "P11.3=?"))  Gets the status of the menu item
(if (= s "")                  If the status is an empty string,
  (menucmd "P11.3=~")         disable the menu item
)

The previous code is not foolproof. In addition to being enabled or disabled, menu items can also receive marks. The code (menucmd "P11.3=?") could return "!.", indicating that the menu item is currently checked. This code would assume that the menu item is disabled and continue without disabling it. If the code included a call to the wcmatch function, it could check the status for an occurrence of the tilde (~) character and then take appropriate action.

The menucmd function also allows AutoLISP programs to take advantage of the DIESEL string expression language. Some things can be done more easily with DIESEL than with the equivalent AutoLISP code. The following code returns a string containing the current day and date:

(menucmd "M=$(edtime,$(getvar,date),DDDD\",\" D MONTH YYYY)")
 returns   "Sunday, 16 July 1995"
See Also
    • The Customization Guide for more information on using AutoLISP to access menu label status, and for information on using DIESEL.