DIESEL Programming for AutoCAD |
Step 1 DIESEL = Direct Interpretively Evaluated String Expression Language AutoCAD is not weded to a single customization tool, so you have got DIESEL just to customize the status bar. As the name suggests, DIESEL is a language that deals mostly with strings. ![]() |
Step 2 It is assumed that you are familiar with some AutoCAD version higher of R12. Also, you understand the importance of the status bar and have prior programming experience with atleast one of the 8 programming paradigms that the open architecture of AutoCAD supports. DIESEL is number nine. (and ARX is No.10) | ![]() . |
Step 3 As commonly perceived, DIESEL is not just a tag language like DCL, but it is also not a full blown programming language with loops, iterations and subfunctions like AutoLISP. Boy ! its different. DIESEL has two major applications in AutoCAD : | ![]() Drop it on the Status Bar |
Step 4 The AutoCAD system variable MODEMACRO can be used to display a new text string in the status line. The value returned by a macro expression using DIESEL can also be displayed in the status bar. Start AutoCAD and type modemacro at the Command: prompt. ![]() As shown in figure above, AutoCAD prompts for a new value. Type a word and press Enter. The word (string) is immediately displayed in the status bar as shown. |
Step 5 Macro expression using DIESEL The return value of a macro expression written using DIESEL can be passsed to the modemacro system variable to be displayed in the status bar. The macro expressions are similar to AutoLISP functions, with some differences. For example, to add two numbers, the AutoLISP function is written as (+ 2 3) whereas, in DIESEL the same thing is written as $(+,2,5) The general syntax for DIESEL expressions is : . | ![]() In DIESEL, the commas between function and the arguments are required, but no spaces are allowed anywhere in the expression |
Step 6 Lets try this out immediately. ![]() Type modemacro at the AutoCAD Command: prompt and press Enter at the keyboard. As shown in figure, type $(+,2,3) without any spaces anywhere in the expression and press Enter. As shown circled red in figure, the return value of the expression is displayed in the status bar, ahead of the coordinate display. |
Step 7 To display the current text style in the status bar, use the expression : | ![]() . |
Step 8 To display the current date with day, month, year and time, use the expression : ![]() The format and output for the edtime function are summarised below : Format : Output D : 5 DD : 05 DDD : Tue H : 2 HH : 02 MM : 23 DDDD : Tuesday M : 1 MO : 11 MON : Nov MONTH : November YY : 92 YYYY : 1992 SS : 12 MSEC : 325 AM/PM : PM am/pm : pm A/P : P a/p : p |
Step 9 DIESEL expressions can get as long as in the previous step. You can integrate AutoLISP and DIESEL. A simple AuoLISP routine that builds DIESEL expressions is shown on the right. Another AutoLISP routine that lets you enter DIESEL expressions directly at the AutoCAD Command: prompt by avoiding the modemacro system variable is available on the Source Code page of the CadGuruCool site at : | (defun c:etm() (setvar "MODEMACRO" (strcat "Text Style : $(getvar,textstyle)" " Elasped Time : $(fix,$(*,60,$(*,24, $(getvar,tdusrtimer))))" ) ) ) |
Step 10 The MACROTRACE system variable is used to debug a DIESEL expression. By default, its value is 0 meaning debugging is OFF. Type MACROTRACE at the AutoCAD Command: prompt and press Enter, then type 1 and press Enter to make DIESEL debugging ON. Next, we will assign a faulty expression to the modemacro system variable. Assign this expression : Notice that in the second expression, the comma between getvar and clayer is missing. AutoCAD displays an error message in the Command: prompt as shown on the right (above) |
|
Step 11 You may want to download another severely indepth and illustrated tutorial on menu programming at : |
|