你好各位大神对文本数字分类求和怎么在CAD2025里不好用
你好各位大神这个插件对文本数字分类求和怎么在CAD2025里不好用能选择等插入点就没有了,麻烦大神帮我修改一下谢谢了。;;--------------------------------------------正则表达式----------------------------------------------------;;
(defun xxexp (pat str key / end)
;(princ "\n ★"一刀屠文"(xxexp)(xxexpr) = 对字符串进行正则表达式测试及替换-by 梁雄啸.2007.7")
(vl-load-com)
(if (not *xxvbsexp)
(setq *xxvbsexp (vlax-get-or-create-object "VBScript.RegExp"))
)
(vlax-put *xxvbsexp 'Pattern pat)
(if (not key)(setq key ""))
(setq key (strcase key))
(setq keys '(("I""IgnoreCase")("G""Global")("M""Multiline")))
(mapcar '(lambda(x)
(if (wcmatch key (strcat "*" (car x) "*"))
(vlax-put *xxvbsexp (read(cadr x)) 0)
(vlax-put *xxvbsexp (read(cadr x)) -1)
))
keys)
(setq matches (vlax-invoke *xxvbsexp 'Execute str))
(vlax-for x matches (setq end (cons (vla-get-value x) end)))
(reverse end)
)
;;--------------------------------------------end----------------------------------------------------;;
;|功能:分类统计求和,如:大叶女贞C 7 大叶女贞B 8大叶女贞C 10,会统计出大叶女贞C 17 大叶女贞B 8
作者:杨春柳 2017.11.10
|;
(defun c:gfsum ( / acaddocument acadobject ent n name namelst newtext num pt sss text textlst txth x)
(setq AcadObject(vlax-get-acad-object)
AcadDocument(vla-get-ActiveDocument AcadObject)
)
(setvar "cmdecho" 0)
(vla-StartUndoMark AcadDocument)
(princ "功能:分类统计求和。作者:孤帆")
(setq sss (ssget ":L" (list '(0 . "text"))))
(setq pt (getpoint "\n指定插入点:"))
(if (and sss pt)
(progn
(setq namelst '() textlst '())
(setq ent (cdr (entget (ssnamesss 0))))
(setq txth (cdr (assoc 40 ent)))
(repeat (setq n (sslength sss))
(setq namelst (cons (vlax-ename->vla-object(ssnamesss (setq n (1- n)))) namelst)))
(setq namelst (mapcar '(lambda (x) (xxexp "[\\-,\\d,\\.]+|[^\\-,\\d,\\.]+" (vla-get-TextString x) "")) namelst))
(foreach name namelst
(if (setq text (assoc (car name) textlst))
(progn
(if (and (= 2 (vl-list-length name)) (numberp (setq num (read (cadr name)))))
(progn
(setq num (+ num (read (cadr text))))
(setq newtext (list (car text) (vl-princ-to-string num)))
(setq textlst (subst newtext text textlst))
)
)
)
(progn
(if (and (= 2 (vl-list-length name)) (numberp (setq num (read (cadr name)))))
(setq textlst (cons nametextlst))
)
)
)
)
(foreach text textlst
(setq text (apply 'strcat text))
(setq ent (subst (cons 1 text)(assoc 1 ent)ent)
ent (subst (cons 10 pt)(assoc 10 ent)ent)
ent (subst (cons 11 pt)(assoc 11 ent)ent))
(entmake ent)
(setq pt (polar pt (* 1.5 pi) (* 1.3 txth)))
)
)
)
(vla-EndUndoMark AcadDocument)
(setvar "CMDECHO" 1)
(princ)
)
页:
[1]