 - (DEFUN C:KK()
- (setq jd (getint "input 精度<0.000>:"))
- (if (= jd nil) (setq jd 0))
- (princ "\nselect object:")
- (setq s (ssget))
- (setq n (sslength s))
- (setq k 0 )(setq mm 0.0)
- (while (< k n)
- (setq name (ssname s k))
- (setq a (entget name))
- (setq t1 (assoc '0 a))
- (setq t1 (cdr t1))
- (if (= t1 "TEXT") (PROGN
- (setq tx (assoc '1 a))
- (setq tx (cdr tx))
- (setq tx (atof tx))
- (setq mm (+ tx mm))
- ))
- (if (= t1 "DIMENSION") (PROGN
- (setq tx (assoc '1 a))
- (setq tx (cdr tx))
- (if (and (/= tx "")(/= tx "<>"))(setq tx (atof tx)))
- (if (or (= tx "")(= tx "<>"))(progn
- (setq tx (assoc '42 a))
- (setq tx (cdr tx))
- ;(setq tx (/ tx 1000))
- ))
- (if (= k 0) (setq MM TX) (setq mm (+ tx mm)))
- ))
- (setq k (+ k 1))
- )
- (setq mm (rtos mm 2 jd))
- (setq po (getpoint "\n指定计算结果的写入点:"))
- (command "text" po "" "" mm)
- )
这个程序可以选择尺寸标注与标高值相加,但有个小数点取值不正确的问题,比如尺寸值是4000,标高值是5.200,程序执行后的结果是4005,而正确的数值应该是9.200,请完善一下这个程序
|