Alert "Hello and Welcome To Autolisp!"
Alert "Hello and Welcome To Autolisp!"
You've tried to decipher some AutoLisp routines but, you are still totally confused!!!
This tutorial will try and teach you the very basics of AutoLisp programming without overwhelming
Let's start up with something very simple and that will give you immediate results. Fire up AutoCad
As you noticed using the (alert) function results in a dialogue box being displayed on your screen.
Let's try something else. Type this at the command prompt and press enter :
(setq a (getpoint))
A "list" of numbers, looking something like this, should appear in your command window.
This list, believe it or not, contains the x, y and z coordinates of the point you picked.
x = 496.04
y = 555.06
z = 0.0
(setq a (getpoint))
Just remember, that you must leave the nest with an equal number of parenthesis. Here's an
example :
You could also write the above statement like this to make it more readable :
(dosomething
(dosomethingelse
(andanotherthing)
Now you can see why "Lisp" is often known as "Lost in Stupid Parenthesis"
You can also add comments to your coding. Anything preceded with a semicolon is not evaluated by
Autolisp and is treated as a comment, much the same way as the REM statement in Basic is used.
e.g.
(dosomething
(dosomethingelse
variable "a".
!a
The point list should be returned. So, any time that you would like to inspect a variable, just precede
Our getpoint function worked, but it didn't really tell the user what was expected from him by way of
Did you notice how Autolisp now asks you for input (and what type of input is expected.)
Type in each of these lines, one at a time, pressing "Enter" at the end of each line, then choosing a
point.
Press "Enter" again. A line should be drawn between the two points.
The (command) function is used to tell AutoCad what you want it to do.
Now this is very nice, but do we have to type in all this coding every time we want to use this routine?