kamig Posted May 1, 2012 Posted May 1, 2012 how to count.dwghello bro, please tell me about the counting in the drawing i have more 100 value in the drawing Example 100 L/s 223 L/s 525 L/s i want total value of this regard, kamran saleem Quote
pBe Posted May 1, 2012 Posted May 1, 2012 (edited) (defun c:addv ( / Total ss e) (vl-load-com) (if (setq total 0 ss (ssget "_X" '((0 . "TEXT")(1 . "*#*L/s")))) (progn (repeat (setq i (sslength ss)) (setq e (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (setq total (+ (atoi (vl-string-right-trim " L/s" (vla-get-textstring e) ) ) total))) [b][color=darkred](alert (strcat "Total=\t" (itoa total)))[/color][/b]) (princ "\nNone Found:") )(princ) ) EDIT: Too many cut and paste, cut and paste, trim. trim. trim Edited May 1, 2012 by pBe Done in haste Quote
Tharwat Posted May 1, 2012 Posted May 1, 2012 Vanilla ... (defun c:addv (/ Total ss i sn) (if (setq total 0 ss (ssget '((0 . "*TEXT") (1 . "*#*L/s"))) ) (progn (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (setq total (+ (atoi (substr (cdr (assoc 1 (entget sn))) 1 (- (strlen (cdr (assoc 1 (entget sn)))) 3) ) ) total ) ) ) (princ (strcat "\nTotal :" (itoa total))) ) (princ "\nNone Found:") ) (princ) ) Quote
Tharwat Posted May 1, 2012 Posted May 1, 2012 Where the heck have you've been hiding Tharwat? I had a very bad sunstroke that kept me sleeping for a week now . Thanks for asking my friend . Quote
kamig Posted May 1, 2012 Author Posted May 1, 2012 thanks boss its working nice but the result is not coming on screen if you can improve the code it will helpfull for us Quote
pBe Posted May 1, 2012 Posted May 1, 2012 (alert (strcat "Total=\t" (itoa total)))) instead (princ (strcat "\nTotal " (itoa total))) 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.