DCL Tutorial 
A little Dialog preview to get
started.....
For Symbols used for Dialog Boxes Check out the Tables
and More section entitled DCL Commands.
Tutorial Title: FirstDCL
1. |
First to get started you need to launch
WordPad or NotePad for this tutorial. Once
launched save the file as FirstDCL.DCL (Note:
Make sure that you save it as a Text file format.
|
2. |
Type the following into the file and then we
will break it down line by line to explain the
code.
|
|
// This Dialog box displays a line of text
with an OK button |
|
|
label = "My First Dialog Box"; |
|
|
label = "Hello there, this is my first
dialog box"; |
Detailed Explanation of the DCL file
// This Dialog box displays a line of text
with an OK button This is a comment line that
can be used with in you DCL files to keep track of what
is going on in that dialog or on that line
FIRSTDCL is the name of the dialog
box in this file. DCL files can contain multiple dialog
boxes and this name is how you keep track of them.
: dialog { is the opening line of the
dialog box.
label = "My First Dialog Box";
is the Title of the dialog box.
: text { is the start of the text
tile which is on the dialog box.
label = "Hello there, this is my first
dialog box..."; is the text that is
displayed by the text tile on the dialog box.
} Closes off the text tile.
ok_only; is a preset command button
tile for an OK button for dialog boxes.
} Closes off the dialog box.
3. |
Save changes to the file and start a new
file. This file will be called FIRSTDCL.LSP.
Notice the only thing that changes between the
two file names is just the extension of the file.
This one must also be saved in a text file format
|
4. |
Type the following into the file and then we
will break it down line by line to explain the
code.
|
|
;; This Routine displays the dialog box
inside of AutoCAD |
|
|
(setq SRT (load_dialog "FIRSTDCL")) |
|
|
(new_dialog "FIRSTDCL" SRT) |
|
|
(action_tile "accept"
"(do_exit)") |
Detailed Explanation of the AutoLISP file
;; This Routine displays the dialog box inside
of AutoCAD This is a comment line that can be
used with in you AutoLISP files to keep track of what is
going on in that routine or on that line
(defun c:MYDCL () is the open line of
the command/ functions. defun stands for
define function. c: doesn't have
anything to do with the C: drive, this stands for command
line function. MYDCL is what is typed in
at the command line to execute the command. () are
used for arguments that need to be passed to the
function.
(defun do_exit () is the opening line
of the function that is going to get executed when
the OK command button is selected in the dialog box..
(done_dialog 1) tells us that the OK
button was selected, if Cancel was a choice for a command
button we would use (done_dialog 0).
) is the ending bracket for the (defun
do_exit () line. In AutoLISP, everything starts
with a bracket and must be closed with a bracket.
(setq SRT (load_dialog "FIRSTDCL"))
In this line we are telling AutoLISP to load the FIRSTDCL.dcl
file and store the DCL identifier in variable SRT.
(if (> SRT 0) Doing a comparison
on SRT and if it is greater than 0 that means
that the file FIRSTDCL.dcl was found in the
search path of AutoCAD.
(progn This function must be used in
conjunction with an if statement if more than one task is
to be completed under the comparison.
(new_dialog "FIRSTDCL" SRT)
Starts the dialog box. It will look for FIRSTDCL
as the section in the DCL file to load, and it will use SRT
as to the file to search through, (SRT is the
DCL identifier of the file).
(action_tile "accept"
"(do_exit)") This line tells AutoLISP
that when the OK button is selected use this as the
function to execute. It will execute the do_exit function
whenever you select the OK button.
(start_dialog) This line actually
makes the user able to interact with the dialog box,
without it the user can't select any of the controls on
it.
(unload_dialog SRT) This line tells
AutoLISP that AutoCAD is done with the dialog box so
close it.
) Balances and closes out the (progn
line.
) Balances and closes out the (if
(> SRT 0) line.
) Balances and closes out the (defun
c:MYDCL () line.
|