CAD AutoLisp 动态五边形
lisp
(defun c:TT()
(setq nn 5)
(setq pt (getpoint "\nGET"))
(setq s t)
(while (and s (setq get (grread 1 0)))
(cond
((equal '(2 97) GET);A键
(setq nn (1- nn))
)
((equal '(2 32) GET);空格
(setq nn (1+ nn))
)
((= 5 (car get));鼠标移动
(command "erase" ent "")
(setq pt1 (cadr Get))
(setq pts (append (list pt1)))
(setq i1 1)
(setq i 2)
(repeat nn
(setq jd (+ (angle pt pt1)(* (* (/ pi 180) (/ 360. nn)) i1)))
(setq cd (distance pt pt1))
(set (read (strcat "PT" (itoa i))) (polar pt jd cd))
(setq pts (append pts (list (eval (read (strcat "PT" (itoa i)))))))
(setq i (1+ i) i1 (1+ i1))
)
(setq ent (entmakex (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length pts)))
(mapcar '(lambda (pt)(cons 10 pt)) pts ))
))
)
((= 3 (car get));鼠标左键
(print "鼠标ddd")
(setq s nil)
)
)
)
)