代码改变世界

AutoCAD LISP绘制四圆孔

2011-03-27 14:43  精诚所至 金石为开  阅读(514)  评论(0编辑  收藏  举报

AutoCAD LISP根据输入角点和圆半径绘制四圆孔,代码如下。

(defun c:test()
  (setvar "cmdecho" 0)
  (setq pt1 (getpoint "\n第一角点:"))
  (setq pt3 (getpoint "\另一角点:"))
  (setq pt2 (list (car pt3) (cadr pt1)))
  (setq pt4 (list (car pt1) (cadr pt3)))
  (setq rr (getdist pt1 "\n圆半径:"))
  (if (null rr) (setq rr 5))
  (command "circle" pt1 rr)
  (setq en1 (entlast))
  (command "line" (polar pt1 pi (+ rr 3)) (polar pt1 0 (+ rr 3)) "")
  (setq en2 (entlast))
  (command "line" (polar pt1 (* pi 1.5) (+ rr 3)) (polar pt1 (/ pi 2) (+ rr 3)) "")
  (setq en3 (entlast))
  (command "copy" en1 en2 en3 "" "m" pt1 pt2 pt3 pt4 "")
  (prin1)
  )

代码完。