About Responding to AutoLISP with DIESEL Expressions in Macros

You can use DIESEL string expressions as a way to provide responses to a command defined with AutoLISP or ObjectARX.

DIESEL expressions return string values (text strings) that can be used as a response to standard commands, AutoLISP, and ObjectARX ® routines, and other macros.

Note: AutoLISP and ObjectARX are not available in AutoCAD LT.

The value returned by a DIESEL expression is a text string, it can be used in response to an AutoLISP getXXX or ObjectARX acetGetXXX function call. This functionality enables menu items to evaluate current drawing conditions and to return a value to an AutoLISP or ObjectARX routine.

If you load and execute the following sample AutoLISP routine, the program prompts for a symbol name and size, and a location in the drawing.

(defun C:SYMIN()
  (setq sym 
    (getstring 
      "\nEnter symbol name: ")      ; Prompts for a symbol name
  )

  (setq 
    siz (getreal 
          "\nSelect symbol size: ") ; Prompts for a symbol size

    p1 (getpoint 
          "\nInsertion point: ")    ; Prompts for insertion point
  )

  (command "._insert"               ; Issues the INSERT command
           sym                      ; using the desired symbol
           p1 siz siz 0)            ; insertion point, and size

 (princ)                            ; Exits quietly 
)
Note: An AutoLISP routine that you use regularly should include error checking to verify the validity of user input.

While the previous example is being executed, you can click user interface elements that execute a DIESEL expression in response to one of the prompts. For example, you might use the expression $M=$(*,$(getvar,dimscale),0.375) to use a scale factor that is 3/8 that of the current DIMSCALE.

This cannot be done with similar AutoLISP code; a value returned by an AutoLISP expression cannot typically be used as a response to a getXXX function call (such as, the getreal function in the preceding sample).