sergiu_ciuhnenco Posted February 18, 2015 Posted February 18, 2015 (edited) In the attached file you will see a plan which show the placing of the stirrups , so I want : To extract all number that are before "x" variable and summ all of them !!! In this case we should obtain 1501. stirrup.dwg Edited February 19, 2015 by sergiu_ciuhnenco Quote
pBe Posted February 19, 2015 Posted February 19, 2015 That's odd, i only get 1437 as total, Numbers before "x" string . i.e "15x100=1500" ? Quote
sergiu_ciuhnenco Posted February 19, 2015 Author Posted February 19, 2015 1501 I do it one more time manualy , same result; You said correct numbers before "x" string for example "15x100=1500"; "5x90=450" Quote
pBe Posted February 19, 2015 Posted February 19, 2015 (edited) I see, apparently there are Mtext character formatting thats why it missed around 6 values with a sum of 64 Will that always be the case? some have and some not formatted? HYG [LM:UnFormat (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)) ) ) ) Edited February 19, 2015 by pBe Quote
sergiu_ciuhnenco Posted February 19, 2015 Author Posted February 19, 2015 It will be better, if it will be a universal lisp , good for all types of dimensions ( formated, unformated ) But about the lisp that you have attached , does not work . ??? Quote
sergiu_ciuhnenco Posted February 19, 2015 Author Posted February 19, 2015 I don't know I try allready several times It show me "Command: (LOAD "C:/Users/S_C/Desktop/text find - копия.lsp") C:SUMMD Command: SUMMD Select objects: Specify opposite corner: 108 found Select objects: ; error: Ошибка Command: " Quote
pBe Posted February 19, 2015 Posted February 19, 2015 (edited) Hang on, i will strip down the code , its probably language issue with RegExp. BTW: what does this mean? Ошибка UPDATE: Nothing to do with RegExp, apparently its just a case of "unicode" encoding Kudos to LM for LM:UnFormat function Edited February 19, 2015 by pBe Quote
sergiu_ciuhnenco Posted February 19, 2015 Author Posted February 19, 2015 Can you attach the lisp file , when a copy the code in mine lisp file it show me something wrong about the unicode file , for me is first time when is appear something like that !!! Quote
sergiu_ciuhnenco Posted February 19, 2015 Author Posted February 19, 2015 Ошибка mean error !!! Quote
pBe Posted February 19, 2015 Posted February 19, 2015 (edited) can you attach the lisp file , when a copy the code in mine lisp file it show me something wrong about the unicode file , for me is first time when is appear something like that !!! hyg summd.LSP Tell me how it goes before i start to modify the code [customize for sergiu] (defun c:summd (/ aDoc Total ss val) (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 (wcmatch (setq val (strcase (vla-get-textoverride e))) "*#X#*") (progn (while (and (setq p (vl-string-position 59 val)) (setq val (substr val (+ 2 p))) (eq (substr val 1 1) "\\") ) ) (setq total (+ (atoi val) total)) ) ) ) (vla-delete ss) (alert (itoa Total)) ) ) ) Edited February 19, 2015 by pBe Might as well Quote
sergiu_ciuhnenco Posted February 19, 2015 Author Posted February 19, 2015 (edited) super !!! it works now, 1501 final result !!! Now I will waste less time . Thanks a lot !!! Edited September 18, 2020 by sergiu_ciuhnenco Quote
pBe Posted February 19, 2015 Posted February 19, 2015 super !!! it works now Phanks a lot !!! I guess that means Thanks [ or is this another case of the "unicode" thingy ] Good for you and you are welcome, glad you had it sorted. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.