菜鸟小白问个lisp的问题
(defun c:mj()(setq pt (getpoint "积书写位置:" ))
(setq sta (bpoly pt))
(if
(= sta nil)
(exit))
(command "area" "" "")
(setq qarea (rtos (getvar "area") 2 2))
(command "layer" "m" "面积" "co" "" "" "")
(command "text" pt "0.4" "" (strcat "=" qarea))
)
错误在哪 没有bpoly这个含数 http://bbs.mjtd.com/data/attachment/album/201602/04/164827fa68yyc776jmm099.jpg啵浪鼓 发表于 2016-2-4 16:09 static/image/common/back.gif
没有bpoly这个含数
但是在visual里显示是蓝色 好吧,bploy是指令,我以为是涵数
(defun c:mj()
(setq pt (getpoint "积书写位置:" ))
(setq sta (bpoly pt))
(if
(= sta nil)
(exit))
(command "area" "e" sta)
(setq qarea (rtos (getvar "area") 2 2))
(command "layer" "m" "面积" "co" "" "" )
(command "text" pt "0.4" "" (strcat "=" qarea))
) 本帖最后由 shh_188 于 2016-2-24 12:01 编辑
(defun c:mj(/ pt sta qarea)
(setq pt (getpoint "积书写位置:" ))
(setq sta (bpoly pt))
(if (= (type sta) 'ENAME)
(if (entget sta)
(progn
(command "area" "e" sta)
(setq qarea (rtos (getvar "area") 2 2))
(command "layer" "m" "面积" "co" "" "" )
(command "text" pt "0.4" "" (strcat "=" qarea))
(entdel sta)
)
)
)
)
你试试看这个吧
你的问题有2个:
一个是对bpoly的返回值注意得不够
一个是,if函数里只能有符合条件与不符合条件的2组表达式,如果表达式超过一个函数的行范围,就要用(progn)括起来
页:
[1]