写了段判断是否生成图元的程序,请大家帮忙测试一下有没有bug
写了段判断是否生成图元的程序,请大家帮忙测试一下有没有bug(defun c:13(/ x)
(setq x (New_en 0))
(if (getpoint "\n 请指定圆心:")
(entmake (list '(0 . "circle") (cons 10 (cadr(grread 3))) (cons 40 (*(getvar"viewsize") 0.02) )))
)
(princ"\n")
(if (New_en x) (strcat "生成 "(rtos(New_en x))" 个图元") )
)
(defun New_en(i / j) ;(setq x (New_enn 0)) ;判断新图元
(entmake (list '(0 . "point") (cons 10 (cadr(grread 3))) ))
(setq j (sslength (ssget "x")) j (if (= (- j i) 0) nil (- j i) ))
(entdel (entlast)) j)
测试了,没发现问题。
似乎也可以这样:
(defun c:13(/ x en)
(setq en (entlast))
(if (getpoint "\n 请指定圆心:")
(entmake (list '(0 . "circle") (cons 10 (cadr(grread 3))) (cons 40 (*(getvar"viewsize") 0.02) )))
)
(princ"\n")
(strcat "生成 "(rtos(New_en en))" 个图元")
)
(defun New_en(en / j);(setq x (New_en enStart)) ;判断新图元
(setq j 0)
(while (setq en (entnext en))
(setq j (1+ j))
)
) happyxt 发表于 2020-10-9 20:05
测试了,没发现问题。
似乎也可以这样:
(defun c:13(/ x en)
谢谢回复,如果dwg中没有任何图元时,程序会出错 是的,如果不在主函数增加判断语句会出错。
改了一下:
(defun c:13(/ en)
(setq en (entlast))
(if (getpoint "\n 请指定圆心:")
(entmake (list '(0 . "circle") (cons 10 (cadr(grread 3))) (cons 40 (*(getvar"viewsize") 0.02) )))
)
(princ"\n")
(strcat "生成 "(itoa(New_en en))" 个图元")
)
(defun New_en(en / j);(setq x (New_en enStart)) ;判断新图元
(cond (en
(setq j 0)
(while (setq en (entnext en))
(setq j (1+ j))
)
)
((ssget "X")
(sslength (ssget "X"))
)
(T 0)
)
)
页:
[1]