AutoLISP卡通图案
2011-03-28 10:29 精诚所至 金石为开 阅读(347) 评论(0) 编辑 收藏 举报AutoLISP卡通图案,代码如下。
(defun c:test()
(setvar "cmdecho" 0)
(setq en (car (entsel "\n选取被切圆:")))
(setq cen2 (getpoint "\n外侧切圆中心点:"))
(setq endata (entget en))
(setq cen1 (cdr (assoc 10 endata)))
(setq rr1 (cdr (assoc 40 endata)))
(setq dd (distance cen1 cen2))
(setq rr2 (- dd rr1))
(if (< rr2 0)
(alert "错误,选取的中心点必须在被切圆外侧")
(progn
(setq ang (- (angle cen1 cen2)))
(command "circle" cen2 rr2)
(setq ciren (entlast))
(command "donut" 0 (/ rr2 2) cen2 "")
(command "mirror" ciren(entlast) "" cen1 (polar cen1 ang rr1) "")
(setq pt1 (polar cen1 (+ ang (/ pi 2)) rr1))
(setq pt2 (polar cen1 ang (- (/ rr1 2))))
(setq pt3 (polar cen1 (- ang (/ pi 2)) rr1))
(command "pline" pt1 pt2 pt3 "")
)
)
(prin1)
)
代码完。