-
Understanding about Lists.
-
Use defun to make function
-
Save Program on Hard Disk
-
Load Lisp file from Hard Disk
-
User Inputs
-
Using Comments
you will most often want to get information from the drawing area of the AutoCAD screen. AutoLISP offers a set of functions just for this purpose. These functions are characterized by their GET prefix. Below Table shows a list of these Get functions along with a brief description.
Functions that pause to allow input
FUNCTION |
DESCRIPTION |
Getpoint |
|
Getcorner |
|
Getorient |
|
Getangle |
|
Getdist |
|
Notethat a Z coordinate value of 0.0 was added and that all the elements of the coordinate list are reals.
Adding Prompts
A rubber-banding line appears from the point previously defined as pt1 just as if you had selected that point manually.
A line is drawn from the point stored by pt1 to the point stored by pt2.
(setq pt1 (getpoint "Pick first corner: "))
(setq pt3 (getcorner pt1 "Pick opposite corner: "))
(setq pt2 (list (car pt3) (cadr pt1)))
(setq pt4 (list (car pt1) (cadr pt3)))
(command "line" pt1 pt2 pt3 pt4 "c" )
It often helps to insert comments into a program as a means of giving a verbal description of the code. below example shows the box program including comments. The comments start with a semicolon and continue to the end of the line. When AutoLISP encounters a semicolon, it will ignore everything that follows it up to the end of the line. Using the semicolon, you can include portions of your Pseudocode as comments to the program code.
; -------------------------------------------------------------------
(defun c:BOX (/ pt1 pt2 pt3 pt4) ;define box function
(setq pt1 (getpoint "Pick first corner: ")) ;pick start corner
(setq pt3 (getpoint pt1 "Pick opposite corner: ")) ;pick other corner
(setq pt2 (list (car pt3) (cadr pt1))) ;derive second corner
(setq pt4 (list (car pt1) (cadr pt3))) ;derive fourth corner
(command "line" pt1 pt2 pt3 pt4 "c") ;draw box) ;close defun
;Function to display relative XY coordinates in status line
;----------------------------------------------------------------------