visual lisp写一个小程序 就在cad中画一个矩形 可以自由改动长宽高 先谢谢 了

 我来答
dnbc1
2012-02-16 · TA获得超过977个赞
知道小有建树答主
回答量:1235
采纳率:92%
帮助的人:404万
展开全部
;试用以下程序
(defun c:ccc()
(setq cm (getvar "cmdecho")
os (getvar "osmode")
)
(setvar "cmdecho" 0)
(command "_undo" "be")

(if (setq pt0 (getpoint "\左下角:"))
(if (setq pt1 (getcorner pt0 "\n右上角:"))
(progn
(setvar "osmode" 0)
(command "_rectang" pt0 pt1)
(while (setq pdbz (getint "\n要改变长宽吗<输入任意整数则改变,回车则结束>:"))
(setq dxy (mapcar '- pt1 pt0)
ent (entlast)
)
(if (= (setq cd (getreal (strcat "\n当前长度为:" (rtos (car dxy) 2 3) ", 请输入改动值:"))) nil)
(setq cd (car dxy))
)
(if (= (setq kd (getreal (strcat "\n当前宽度为:" (rtos (cadr dxy) 2 3) ", 请输入改动值:"))) nil)
(setq kd (cadr dxy))
)
(if (not (equal dxy (list cd kd)))
(command "_erase" ent ""
"_rectang" pt0 (mapcar '+ pt0 (list cd kd))
)
)
)
)
)
)

(command "_undo" "e")
(setvar "osmode" os)
(setvar "cmdecho" cm)
(princ)
)
追问
在这个基础上能不能可以选择任何填充图案进行填充
追答
可以,以下程序未加入对填充图案名是否存在的判断
;试用以下程序
(defun c:ccc()
(setq cm (getvar "cmdecho")
os (getvar "osmode")
)
(setvar "cmdecho" 0)
(command "_undo" "be")

(if (setq pt0 (getpoint "\左下角:"))
(if (setq pt1 (getcorner pt0 "\n右上角:"))
(progn
(setvar "osmode" 0)
(command "_rectang" pt0 pt1)
(while (setq pdbz (getint "\n要改变长宽吗:"))
(setq dxy (mapcar '- pt1 pt0)
ent (entlast)
)
(if (= (setq cd (getreal (strcat "\n当前长度为:" (rtos (car dxy) 2 3) ", 请输入改动值:"))) nil)
(setq cd (car dxy))
)
(if (= (setq kd (getreal (strcat "\n当前宽度为:" (rtos (cadr dxy) 2 3) ", 请输入改动值:"))) nil)
(setq kd (cadr dxy))
)
(if (not (equal dxy (list cd kd)))
(command "_erase" ent ""
"_rectang" pt0 (mapcar '+ pt0 (list cd kd))
)
)
)
(if (= (setq tam (getstring "\n输入图案名:")) "")
(setq tam "ANGLE")
)
(if (= tam "SOLID")
(command "_hatch" tam (entlast) "")
(command "_hatch" "ANGLE" "" "" (entlast) "")
)
)
)
)

(command "_undo" "e")
(setvar "osmode" os)
(setvar "cmdecho" cm)
(princ)
)
snddd2000
2012-02-16 · TA获得超过4270个赞
知道大有可为答主
回答量:2266
采纳率:0%
帮助的人:1673万
展开全部
怎么个改法?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式