DIESEL Expressions in Menus

You can implement DIESEL string expressions in menu files and use them as an additional method of creating macros. These expressions can return string values in response to standard AutoCAD LT commands. They can also return string values to the menu itself, thereby altering the appearance or content of a menu label.

A DIESEL expression that you use in a menu item must follow the $section=submenu format where the section name is M and the submenu is the DIESEL expression you want.

Consider the following example.

[Ps/Ms]^C^C^P$M=$(if,$(=,$(getvar,cvport),1),mspace,pspace)

This string provides a way to toggle between paper space and model space if TILEMODE is set to 0. This expression is evaluated transparently. If the special character ^P (which toggles MENUECHO on and off) is omitted, the expression displays only the issued command.

The next example is based on these assumptions:

The DIMSCALE dimensioning variable is set to the drawing's scale factor; that is, a drawing to be plotted at a scale of 1" = 10' would have a scale factor of 120, or a 1/4" = 1' scale drawing would have a scale factor of 48.

The DIESEL expressions in the following menu file excerpt multiply the current value of DIMSCALE by the specified value and return an appropriate scaling factor.

**symsize 3
[ SIZES ]

[ 3/8" ]$M=$(*, $(getvar,dimscale),0.375)
[ 1/2" ]$M=$(*,$(getvar,dimscale),0.5)
[ 5/8" ]$M=$(*,$(getvar,dimscale),0.625)

DIESEL expressions can also return string values to pull-down menu item labels, so that you can gray out or otherwise alter the way the menus are displayed. To use a DIESEL expression in a pull-down menu label, you must be sure that the first character is the $ character.

In the next example, the current layer is set to BASE and the following is used as the label portion of a ***POPn section in a menu file.

[$ (eval,"Current layer: " $(getvar,clayer))]

The result is that the appropriate pull-down menu is displayed and updated whenever the current layer changes.

Current Layer: BASE

Note: The width of pull-down and cursor menus is determined when the menu file is being loaded. Menu labels generated or changed by DIESEL expressions after a menu is loaded are truncated to fit within the existing menu width.

If you anticipate that a DIESEL-generated menu label will be too wide, you can use the following example to ensure that the menu width will accommodate your labels. This example displays the first 10 characters of the current value of the USERS3 system variable.

[$ (eval,"Current value: " $(getvar,users3))+
$(if, $(eq,$(getvar,users3),""), 10 spaces )]^C^Cusers3

You cannot use trailing spaces in a menu label to increase the menu width, because trailing spaces are ignored when the menu is being loaded. Any spaces you use to increase the width of a menu label must be within a DIESEL expression.

The next example uses the same DIESEL expression as the label and a portion of the menu item. It provides a practical way to enter the current day and date into a drawing.

[$(edtime,$(getvar,date),DDD", "D MON YYYY)]^C^Ctext +
\\\ $M=$(edtime,$(getvar,date),DDD", "D MON YYYY);

Also, you can use a DIESEL macro to gray out or mark pull-down menu labels. The following pull-down menu label displays a grayed-out (and unselectable) ERASE while a command is active. The text is displayed normally when a command is not active.

[ $(if,$(getvar,cmdactive),~)ERASE]erase

You can use a similar approach to place a mark beside a pull-down menu item or to interactively change the character used for the mark.

Note: The use of DIESEL in menu labels is platform specific; some platforms do not update menu labels after loading the menu file initially.