CAD lisp 程序中出现参数类型错误: numberp: nil,怎么修改,请指教~!
(defun c:gw()
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(prompt "选取钢号")
(setq a (ssget ))
(setq n 0)
(setq ename (ssname a n))
(setq a1 (entget ename))
(setq aa (cdr (assoc 1 a1)))
(setq a (atof aa))
(prompt "选取根数")
(setq b (ssget))
(setq n 0)
(setq ename (ssname b n))
(setq b1 (entget ename))
(setq bb (cdr (assoc 1 b1)))
(setq b (atof bb))
(prompt "选取单长")
(setq c (ssget))
(setq n 0)
(setq ename (ssname c n))
(setq c1 (entget ename))
(setq cc (cdr (assoc 1 c1)))
(setq c (atof cc))
(setq d (* b c 0.001))
(if (= a 6)
(setq e 0.222))
(if (= a 8)
(setq e 0.395))
(if (= a 10)
(setq e 0.617))
(if (= a 12)
(setq e 0.888))
(if (= a 14)
(setq e 1.208))
(if (= a 16)
(setq e 1.578))
(if (= a 18)
(setq e 1.998))
(if (= a 20)
(setq e 2.466))
(if (= a 22)
(setq e 2.984))
(if (= a 25)
(setq e 3.853))
(if (= a 28)
(setq e 4.833))
(if (= a 32)
(setq e 6.313))
(setq f (* e d ))
(setq d (rtos d 2 3))
(prompt "选取修改总长")
(setq x (ssget))
(setq x (ssname x 0))
(setq x1 (entget x))
(setq x1 (subst (cons 1 d) (assoc 1 x1) x1))
(entmod x1)
(setq f (rtos f 2 1))
(prompt "选取修改总重")
(setq x (ssget))
(setq x (ssname x 0))
(setq x1 (entget x))
(setq x1 (subst (cons 1 f) (assoc 1 x1) x1))
(entmod x1)
) 展开
程序是没有错的。不过你可能是选择的有问题。
;我修改了一下
;----------------------------------------------------------------------
(defun c:gw ()
(setq olddz (getvar "dimzin"))
(setvar "dimzin" 0)
(setvar "blipmode" 0)
(prompt "选取钢筋直径:")
(setq a (ssget))
(setq ename (ssname a 0))
(setq a1 (entget ename))
(setq aa (cdr (assoc 1 a1)))
(setq a (atof aa))
(prompt "选取根数:")
(setq b (ssget))
(setq ename (ssname b 0))
(setq b1 (entget ename))
(setq bb (cdr (assoc 1 b1)))
(setq b (atof bb))
(prompt "选取单长:")
(setq c (ssget))
(setq ename (ssname c 0))
(setq c1 (entget ename))
(setq cc (cdr (assoc 1 c1)))
(setq c (atof cc))
(setq d (* b c 0.001))
(setq e (rtos (* 0.006165375 a a) 2 3))
(setq e (atof e))
(setq f (* e d))
(setvar "dimzin" 8)
(setq d (rtos d))
(prompt "选取修改总长:")
(setq x (ssget))
(setq x (ssname x 0))
(setq x1 (entget x))
(setq x1 (subst (cons 1 d) (assoc 1 x1) x1))
(entmod x1)
(setvar "dimzin" 8)
(setq f (rtos f 2 3))
(prompt "选取修改总重:")
(setq x (ssget))
(setq x (ssname x 0))
(setq x1 (entget x))
(setq x1 (subst (cons 1 f) (assoc 1 x1) x1))
(entmod x1)
(setvar "dimzin" olddz)
(princ)
)
我没有把钢筋等级和直径放在一起,加载程序以后可以选取钢筋直径,根数,单长,但是到该选取修改总长的时候命令就结束了,在同事的电脑上也是这样,然后提示参数类型错误。。。