Save time, and automate your tasks !!!
Lesson no. 1
- AutoLisp programs are external files that have".lsp" extension (ex: lesson-1.lsp). We must load them into memory beforeusing them. A lot of ways are possible to load them. But for now, we willdo it by typing the instructions in the command prompt.
COMMAND: (load"c:/program/lisp/lesson-1")
C:LESSON-1Here, i just loaded "lesson-1.lsp" and thefile is in "c:\program\lisp". As you can see, we use the forward slash(/) ....
The backslash (\) is reserved for specialsevents. After the loading, AutoCAD returns "C:LESSON-1"....
This mean that the program is into memory....It also indicates the name of the new AutoCAD command.
To start the routine, we just type the name:COMMAND: lesson-1
- We use text editors to write AutoLISP program.We save them as "text only" with the ".lsp" extension (ex: lesson-1.lsp)
See what the file "lesson-1.lsp" look like
(defunc:lesson-1 ( )
(initget7)
(setq rep(getint"\nHowold are you ?:"))
(if(>rep 21)
(alert"Youcan drive my car")
(alert "You mustwait a few years")
)
)
This program is very small, but it showsyou the way to write a lisp file. The most common errors, when you startto write AutoLisp files, are the parenthesis and the double quotes. Infact, you must always have the same amount of open
parenthesis and closing parenthesis....andalways have a odd number of double quotes.