求cad的一个lisp程序,要求鼠标在点击一点后,输入长、宽两个数值,就能出来矩形,并且自动画出矩形的对角线

2024-11-29 05:25:14
推荐回答(1个)
回答(1):

(defun c:hk ()
(setq xy1 (getpoint "请点击矩形左下角:")
kd (getreal "请输入宽度:")
cd (getreal "请输入长度:")
xy2 (polar xy1 0 cd)
xy3 (polar xy2 (angtof "90") kd)
xy4 (polar xy1 (angtof "90") kd)
)
(command "pline" xy1 xy2 xy3 xy4 "c")
(command "line" xy1 xy3 "")
(setq a (entlast))
(command "change" a "" "p" "lt" "x0" "")
(command "line" xy2 xy4 "")
(setq a (entlast))
(command "change" a "" "p" "lt" "x0" "")
)
试一试,是不是这个效果,,