通过Lisp语言编写在AutoCAD上绘制五角星的程序
(defun C:hzwjx(/ ss cc pc r r0 r1 r2 r3 r4 t0 tt p0 p1 p2 p3 p4) ;定义函数名称、哑元和局部变量
(setq ss (getvar "osmode")) ;保存系统变量"osmode"的值
(setq cc (getvar "CECOLOR"))
(setvar "osmode" 512) ;设定"osmode"的新值,"512"表示捕捉最近点
(prompt "\n先画圆:采用圆心和半径式")
(setq pc (getpoint "\n圆心") p0 (getpoint pc "\n圆周上点"))
(setq r (distance pc p0))
(setq t0 (/ 3.1415926 2))
(star t0 p0 pc r)
(setvar "osmode" ss) ;恢复原来的目标捕捉方式
(setvar "CECOLOR" cc)
)
(defun star (t0 p0 pc r / tt p1 p2 p3 p4 r0 r1 r2 r3 r4)
(setq tt (/ (* 2 3.1415926) 5))
(command "color" 2)
(setq e1(entlast))
(setq p0 (polar pc t0 r)
p1 (polar pc (+ t0 tt