CAD AutoLisp 输入边数绘制多边形
输入多边形边数,选择半径长度绘制多边形
lisp
(defun c:TT()
(setq nn (getint "\n输入数字"))
(setq pt (getpoint "\nGET"))
(setq pt1 (getpoint pt "\nGET"))
(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))
)
(entmake (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length pts)))
(mapcar '(lambda (pt)(cons 10 pt)) pts ))
)
(princ)
)