求cad的一个lisp程序,要求鼠标在点击一点后,输入长、宽两个数值,就能出来矩形,并且自动画出矩形的对角线
要求鼠标在任意位置点击一点后,提示输入长、宽两个数值,就能出来矩形,并且自动画出矩形的对角线,对角线为虚线...
要求鼠标在任意位置点击一点后,提示输入长、宽两个数值,就能出来矩形,并且自动画出矩形的对角线,对角线为虚线
展开
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" "")
)
试一试,是不是这个效果,,
(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" "")
)
试一试,是不是这个效果,,
更多追问追答
追问
你好,已经很不错了,不过再帮个忙,我想能不能一下子就出来两条黄色的对角虚线。因为做选择题也麻烦。
追答
(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" "c" "2" "")
(command "line" xy2 xy4 "")
(setq a (entlast))
(command "change" a "" "p" "lt" "x0" "c" "2" "")
)
好了,选最佳答案
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询