Jump to content

Recommended Posts

Posted

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....

Posted

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)
)

Posted (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 by Lee Mac
Posted

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

Posted

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.

Posted
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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...