The Autolisp Tutorials - Dcl - AfraLisp.pdf

(1792 KB) Pobierz
file://C:\book\cover.htm
The
AutoLisp
Tutorials
DCL-Dialog Control Language
Written and Compiled by Kenny Ramage
afralisp@mweb.com.na
http://www.afralisp.com
68934526.008.png 68934526.009.png 68934526.010.png 68934526.011.png 68934526.001.png 68934526.002.png 68934526.003.png
Copyright ©2002 Kenny Ramage, All Rights Reserved.
afralisp@mweb.com.na
http://www.afralisp.com
This publication, or parts thereof, may not be reproduced in any form, by any method, for any
purpose, without prior explicit written consent and approval of the author.
The AUTHOR makes no warranty, either expressed or implied, including, but not limited to
any implied warranties of merchantability or fitness for a particular purpose, regarding these
materials and makes such materials available solely on an "AS -IS" basis. In no event shall
the AUTHOR be liable to anyone for special, collateral, incidental, or consequential damages
in connection with or arising out of purchase or use of these materials. The sole and
exclusive liability to the AUTHOR, regardless of the form of action, shall not exceed the
purchase price of the materials described herein.
The Author reserves the right to revise and improve its products or other works as it sees fit.
This publication describes the state of this technology at the time of its publication, and may
not reflect the technology at all times in the future.
AutoCAD, AutoCAD Development System, AutoLISP, Mechanical Desktop, Map, MapGuide,
Inventor, Architectural Desktop, ObjectARX and the Autodesk logo are registered trademarks
of Autodesk, Inc. Visual LISP, ACAD, ObjectDBX and VLISP are trademarks of Autodesk, Inc.
Windows, Windows NT, Windows 2000, Windows XP, Windows Scripting Host, Windows
Messaging, COM, ADO®, Internet Explorer, ActiveX®, .NET®, Visual Basic, Visual Basic for
Applications (VBA), and Visual Studio are registered trademarks of Microsoft Corp.
All other brand names, product names or trademarks belong to their respective holders.
 
Contents
Page Number
Chapter
Page 4
Getting Started
Page 13
Dialog Box Layout
Page 30
Dialog Boxes Step by Step
Page 55
Dialog Boxes in Action
Page 62
Nesting and Hiding Dialogs.
Page 74
Hiding Dialogs Revisited.
Page 82
AutoLisp Message Box.
Page 93
AutoLisp Input Box.
Page 95
Referencing DCL Files.
Page 103
Functional Synopsis of DCL Files.
Page 196
DCL Attributes.
Page 255
Dialog Box Default Data.
Page 266
Attributes and Dialog Boxes
Page 274
DCL without the DCL File
Page 283
DCL Model.
Page 317
Acknowledgements and Links
68934526.004.png
Getting Started With DCL
Dialog Control Language, or DCL, always seems to frighten off a lot of Lispers. I admit, it did me too until
I was forced into a situation were I had to learn it and quickly. (make it work, or you're out boy!)
Well, I would hate for any of you to be in the same situation, so for the next few issues, I'll be taking you
step by step, hand in hand, through the minefield of the DCL language. I will share your pain and misery,
and will wipe away your tears, I will.....
("Hey Kenny, get on with it!")
Oops, sorry!
Anyway, where was I? Oh yeah, I will suffer.......(thump!!)
As I was saying before I got this black eye, there are a few terms that you need to familiarise yourself
with before we get stuck into some coding.
Firstly, the dialog box itself is known as a "dialog definition".
Secondly, each "control" on the dialog is known as a "tile definition".
Thirdly, each "property" of a "tile" is known as a dialog "attribute".
And fourthly, each "method" of a "tile" is known as an "action expression".
Why? Who knows? Who cares? All I know is that it will help you immensely in understanding the
AutoCAD DCL reference book if you have a basic knowledge of these terms.
Right, enough waffle, I'm bored and my eye's sore. Let's have a look at some DCL coding and design
ourselves a simple dialog box.
Copy and paste this into Notepad and save it as "TEST_DCL1.DCL".
Oh, before I forget, please ensure that you save this file, and it's namesake AutoLisp file, into a directory
that is within your AutoCAD search path.
//DCL CODING STARTS HERE
test_dcl1
: dialog
{
label = "Test Dialog No 1";
: text
{
label = "This is a Test Message";
alignment = centered;
}
: button
{
key = "accept";
label = "Close";
is_default = true;
fixed_width = true;
alignment = centered;
}
}
//DCL CODING ENDS HERE
68934526.005.png
We'll have a closer look at what this all means a bit later. First, let's load some AutoLisp coding and try
out our new dialog box.
Copy and paste this into Notepad and save it as "TEST_DCL.LSP".
;AUTOLISP CODING STARTS HERE
(prompt "\nType TEST_DCL1 to run.....")
(defun C:TEST_DCL1 ()
(setq dcl_id (load_dialog "test_dcl1.dcl"))
(if (not (new_dialog "test_dcl1" dcl_id))
(exit )
);if
(action_tile "accept"
"(done_dialog)"
);action_tile
(start_dialog)
(unload_dialog dcl_id)
(princ)
);defun
(princ)
;AUTOLISP CODING ENDS HERE
Now load and run your program.
A very simple dialog box containing a message should appear on your screen. It did? Good, well done!!
(thunderous applause from the peanut gallery.)
Right, let's dissect the DCL coding.
(theme music from an old Dracula movie starts in the background.)
//DCL CODING STARTS HERE
Anything starting with // in DCL is regarded as a comment.
test_dcl1
The name of the dialog.
: dialog
68934526.006.png 68934526.007.png
Zgłoś jeśli naruszono regulamin