lisp做数字求和,怎么把结果复制到剪贴板,然后我可以点一下就可以直接粘贴到该位置,还有怎么获取到例如“管540.1钉1余26”这种文字数字混合里的所有数字求和,搞了一下午都没成功,求大佬
代码如下:
(defun c:cc(/ all endno aa bb cc wz tha tsum i)
(if (null xzz) (setq xzz 0))
(setq ALL (ssget(list (cons 0 "text"))))
(if all (SETQ nn (SSLENGTH ALL)))
(setq endno 0)
(setq tsum 0 i 0)
(WHILE (and (< endno nn) all)
(setq aa (ssname all endno))
(setq bb (entget aa))
(setq cc(cdr(assoc 1 bb)))
(setq cc1(vl-string-right-trim "米Mm" cc))
(setq wz(rdata cc1))
(setq tha(substr cc (+ wz 1) ( - (strlen cc) wz -1)))
(if (= tha "") (setq tha "0"))
(setq tsum(+ tsum (atof tha)))
(setq i(1+ i))
(setq endno (+ endno 1))
)
(princ(tsum))
)
(defun rdata(str / len i aa)
(if (> (strlen str) 0)
(progn
(setq i (strlen str))
(setq aa(substr str (strlen str) 1))
(while (and (or (and (>= aa "0") (<= aa "9"))
(= aa ".")
)
(>= i 1)
)
(setq i(1- i))
(if (>= i 1) (setq aa(substr str i 1)))
)
)
)
(setq i i)
)
代码如下:
(defun c:cc(/ all endno aa bb cc wz tha tsum i)
(if (null xzz) (setq xzz 0))
(setq ALL (ssget(list (cons 0 "text"))))
(if all (SETQ nn (SSLENGTH ALL)))
(setq endno 0)
(setq tsum 0 i 0)
(WHILE (and (< endno nn) all)
(setq aa (ssname all endno))
(setq bb (entget aa))
(setq cc(cdr(assoc 1 bb)))
(setq cc1(vl-string-right-trim "米Mm" cc))
(setq wz(rdata cc1))
(setq tha(substr cc (+ wz 1) ( - (strlen cc) wz -1)))
(if (= tha "") (setq tha "0"))
(setq tsum(+ tsum (atof tha)))
(setq i(1+ i))
(setq endno (+ endno 1))
)
(princ(tsum))
)
(defun rdata(str / len i aa)
(if (> (strlen str) 0)
(progn
(setq i (strlen str))
(setq aa(substr str (strlen str) 1))
(while (and (or (and (>= aa "0") (<= aa "9"))
(= aa ".")
)
(>= i 1)
)
(setq i(1- i))
(if (>= i 1) (setq aa(substr str i 1)))
)
)
)
(setq i i)
)