You are on page 1of 13

AutoLISP

1960
.
AutoLISP LISP AutoCAD
. AutoLISP AutoCAD

AutoCAD .

AutoLISP TEXT EDITOR .
AutoCAD load .

(LISP)

1. Text Editor .
layer .
(defun c:lm() --> (lm:)
(setvar "cmdecho" 0)
(command "layer" "m" "1" "c" "green" ""
"m" "2" "c" "red" ""
"m" 3" "c" "yellow" ""

"m" "4" "c" "white" ""


"m" "5" "c" "red" "" "it" "centerx2" ""
"m" "6" "c" "magenta" "" "It" "phantom" ""
"m" "7" "c" "cyan" "" "It" "phantomx2" ""
"m" "8" "c" "yellow" "" "It" "hidden" "" ""
)
(command "layer" "s" "2" "")
(princ)
)

2. *.lsp .
makelayer.lsp . AutoCAD support
.

3. AutoCAD load .
command : appload( ) -->

4. LISP .
command : lm -->
(defun ) .
, lm (setvar)~(pric) .

(command) AutoCAD . " "


.
enter
: (command "layer" "m" "1" "c" "green" "")
AutoCAd :
Command: layer
Current layer: "0"
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/Lweight/Plot/Freeze/Thaw/Lock/Unlock]: m
Enter name for new layer (becomes the current layer) <0>: 1
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/Lweight/Plot/Freeze/Thaw/Lock/Unlock]:
Center color name or number (1-255): green
Enter name list of layer(s) for color 3 (green) <1>:
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/Lweight/Plot/Freeze/Thaw/Lock/Unlock]:

Enter .

,
lm .

http://www.gumji.info/

acad.pgp .

.

1. Line

Notepad.exe
(:test1.lsp LSP)
load .

(defun c:Li() (command "LINE"))

"line" "Li" .
c: "Li" .
"aa"

(defun c:aa() (command "LINE")) .

2. (defun ?
. (defun .
. "(" .

3. c: ?
command .
"c:" .
.
"Li" () . . .

4. (command "line")?
command .
"line"
.
!

(command "line" "0,0" "100,100")

(0,0) (100,100) .
.

(command "circle" "0,0" "10")

(0,0) 10 .
center point,
.

5. "(" ")" .
.

.
.
"1+2"
(+ 1 2) .

1. () .
.

2. !! .

3. .
.
123 + 456 -> (+ 123 456)
123 x 456 -> (* 123 456)
546 - 123 -> (- 546 123)
345 / 123 -> (/ 345 123)

4.

.
1 + 2 + 3 + 4 + 5 -> (+ 1 2 3 4 5)
5 x 4 x 3 x 2 x 1 -> (* 1 2 3 4 5)

,
.
1 + ( 3 x 4 ) -> (+ 1 ( * 3 4))
( 4 / 2 ) -4 -> (- (/ 4 2) 4)

5. .
command :
. .
command: (+ 1 3)
(+ 1 3) . '4' .

.

.

1. ?

.

3.131492 .
3.141592 pi
pi 3.141592 .


(setq pi 3.141592)
.

2. (setq ?
. .
.

3. (setq A B)
B A , .
.

4.
(setq test1 3456.789)
3456.789 test1
. test1 3456.789
.
test1 <-- 3456.789 ,
test1 = 3456.789 .

.
(setq test1 123)
(setq test2 456)
(setq test3 (+ test1 test2))

test1 123 , test2 456 .


test3 test1+test2 123+456 , 579 .

5.
(setq test4 "this is sample")

!! " " . !!
test4 this is sample .

6.
, .
,
.

()

.
1. ...
(setq a 1)
(setq b 2)
(setq c 3)

a=1, b=2, c=3 .


.
(setq a 1 b 2 c 3)

. 1:1
(setq ,
.

(setq a 1
b2
c 3)

.
.

2. () .
(;) .
.

; .
(defun c:test()
; .
(setq a 1

; a 1 .
b2

; b 2 .

c3

; c 3 .

d (+ a b c)) ; a+b+c d .
)
; .
); end of defun

(;)
.
.
.

.
.

You might also like