用autolisp在AutoCAD里面画一个圆角矩形
时间: 2023-07-04 13:17:40 浏览: 226
下面是使用AutoLISP在AutoCAD中绘制圆角矩形的代码。首先打开AutoCAD软件,创建一个新的绘图文件,然后按下“Alt+F11”进入Visual LISP编辑器,输入以下代码:
```lisp
(defun c:arc-rect (/ p1 p2 width height fillet rad pt1 pt2 pt3 pt4)
(setq p1 (getpoint "\n输入第一个角点:"))
(setq p2 (getcorner p1 "\n输入第二个角点:"))
(setq width (abs (- (car p2) (car p1))))
(setq height (abs (- (cadr p2) (cadr p1))))
(setq fillet (getdist "\n输入圆角半径:"))
(setq rad (/ fillet (sqrt 2)))
(setq pt1 (list (+ (car p1) rad) (+ (cadr p1) height)))
(setq pt2 (list (+ (car p1) width) (+ (cadr p1) height-rad)))
(setq pt3 (list (+ (car p1) width-rad) (+ (cadr p1) )))
(setq pt4 (list (+ (car p1)) (+ (cadr p1) rad)))
(command "._pline" pt1 (polar pt1 (/ pi 2) (* -1 rad)) (polar pt2 0 rad) pt2 (polar pt3 (/ pi 2) rad) (polar pt4 pi (* -1 rad)) pt4 (polar pt1 pi rad) "C")
(princ)
)
```
然后保存文件,回到AutoCAD软件界面,输入“arc-rect”,按回车键,根据提示输入第一个角点、第二个角点和圆角半径,即可绘制出圆角矩形。
阅读全文