我明白了,显然有多行文字字符格式,这就是为什么它丢失了大约6个值,总和为64
会一直是这样吗?有些已经格式化,有些没有格式化?
HYG[LM:非格式化
- (defun c:summd (/ LM:UnFormat Total ss val)
- (defun LM:UnFormat (str mtx / _Replace regex)
- (vl-load-com)
- ;; © Lee Mac 2010
- (defun _Replace (new old str)
- (vlax-put-property regex 'pattern old)
- (vlax-invoke regex 'replace str new)
- )
- (setq regex (vlax-get-or-create-object "VBScript.RegExp"))
- (mapcar
- (function
- (lambda (x) (vlax-put-property regex (car x) (cdr x)))
- )
- (list (cons 'global actrue)
- (cons 'ignorecase acfalse)
- (cons 'multiline actrue)
- )
- )
- (mapcar
- (function
- (lambda (x) (setq str (_Replace (car x) (cdr x) str)))
- )
- '(
- ("Ð" . "\\\\\\\")
- (" " . "\\\\P|\\n|\\t")
- ("$1"
- .
- "\\\\(\\\\[ACcFfHLlOopQTW])|\\\\[ACcFfHLlOopQTW][^\\\\;]*;|\\\\[ACcFfHLlOopQTW]"
- )
- ("$1$2/$3" . "([^\\\\])\\\\S([^;]*)[/#\\^]([^;]*);")
- ("$1$2" . "\\\\(\\\\S)|[\\\\](})|}")
- ("$1" . "[\\\\]({)|{")
- )
- )
- (setq str
- (if mtx
- (_Replace
- "\\\"
- "Ð"
- (_Replace "\\$1$2$3" "(\\\\[ACcFfHLlOoPpQSTW])|({)|(})" str)
- )
- (_Replace "\" "Ð" str)
- )
- )
- (vlax-release-object regex)
- str
- )
- (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object))
- Total 0
- )
- (if (ssget '((0 . "*DIMENSION")
- (-4 . "<OR")
- (1 . "*?*")
- (-3 ("ACAD"))
- (-4 . "OR>")
- )
- )
- (progn
- (vlax-for e (setq ss (vla-get-ActiveSelectionSet aDoc))
- (if
- (vl-string-position
- 88
- (strcase (setq val (LM:UNFORMAT (vla-get-textoverride e) t))
- )
- )
- (setq total (+ (atoi val) total))
- )
- )
- (vla-delete ss)
- (alert (itoa Total))
- )
- )
- )
|