tanveer4m Posted July 23, 2012 Posted July 23, 2012 I am looking for a lisp that can Sum up all the dimension & give a singlevalue so that I can easily get quantity of lines.... Quote
Tharwat Posted July 23, 2012 Posted July 23, 2012 Check this ... (defun c:Test (/ ss n) (if (setq ss (ssget '((0 . "*DIMENSION")))) (progn (setq n 0) ((lambda (x / sn) (while (setq sn (ssname ss (setq x (1+ x)))) (setq n (+ (cdr (assoc 42 (entget sn))) n)) ) ) -1 ) (if (> n 0) (alert (strcat "Total value of seleced Dimensions is : <" (rtos n 2) " >" ) ) ) ) (princ) ) (princ) ) Quote
Lee Mac Posted July 23, 2012 Posted July 23, 2012 (edited) Here is a very simple solution: (defun c:dimsum ( / i s x ) (if (setq s (ssget '( (0 . "DIMENSION") (-4 . "<OR") (70 . 000) (70 . 001) (70 . 032) (70 . 033) (70 . 128) (70 . 129) (70 . 160) (70 . 161) (-4 . "OR>") ) ) ) (progn (setq x 0.0) (repeat (setq i (sslength s)) (setq x (+ x (cdr (assoc 42 (entget (ssname s (setq i (1- i)))))))) ) (princ (strcat "\nTotal of " (itoa (sslength s)) " Dimensions: " (rtos x))) ) ) (princ) ) Edited July 30, 2012 by Lee Mac Quote
tanveer4m Posted July 25, 2012 Author Posted July 25, 2012 Thanks for the LISP. It works great. If there are edited dimension while calculating it should prompt saying that whether to inclue text override or not? Thanks Tanveer Quote
evylrat Posted July 30, 2012 Posted July 30, 2012 So close... if the Dim's text has been moved, the Lisp routine will not count it. I had to do a DimTedit, Home on all the dims before this gave the correct Sum. Also, it's uses the full precision, not the precision of the dim. Eg, if I have four 99.5mm dims, all rounded down, I'd expect the sum to be 396 (not 398) which lets me know I've got to round up 2 of the dims. Quote
Lee Mac Posted July 30, 2012 Posted July 30, 2012 So close... if the Dim's text has been moved, the Lisp routine will not count it. I had to do a DimTedit, Home on all the dims before this gave the correct Sum. I had overlooked the combination of bit-codes 2 & 8 and have now updated the above code. Also, it's uses the full precision, not the precision of the dim. The program will use the precision set by the LUPREC System Variable. 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.