代码改变世界

AutoCAD矩形交叉口框短边切圆一

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

AutoCAD矩形交叉口框短边切圆,绘制长方形,并以中心为圆形短边为半径画圆,并截取对角线,代码如下。

(defun c:test()
  (setvar "cmdecho" 0)
  (setq pt1 (getpoint "\n第一角点:"))
  (setq pt3 (getcorner pt1 "\n另一角点:"))
  (setq pt2 (list (car pt3) (cadr pt1)))
  (setq pt4 (list (car pt1) (cadr pt3)))
  (command "rectang" pt1 pt3)
  (setq int (inters pt1 pt3 pt2 pt4))
  (setq ww (distance pt1 pt2))
  (setq hh (distance pt2 pt3))
  (setq cir1 (/ (min ww hh) 2))
  (command "circle" int cir1)
  (setq en1 (entlast))
  (command "line" pt1 pt3 "")
  (setq en2 (entlast))
  (command "line" pt2 pt4 "")
  (setq en3 (entlast))
  (command "trim" en1 "" (list en2 pt1) (list en2 pt3) (list en3 pt2) (list en3 pt4) "")
  (prin1)
  )

代码完。