Sum of Dimension text

Sum of Dimension text

LoganAC34
Advocate Advocate
10,803 Views
25 Replies
Message 1 of 26

Sum of Dimension text

LoganAC34
Advocate
Advocate

I need a LISP that can total the selected dimensions and display the totaled amount. I've seen a lot of posts with a similar function but they don't quite do exactly what I want. They all sum the actual value of a dimension rather than the amount displayed in the text of the dimension line in the drawing. 

 

For example in the drawing attached the two dimensions within the 2'-10 7/8" dimension do not add up to 2'-10 7/8". Due to precision and rounding, they instead add up to 2'-10 15/16".  Sometimes this happens, sometimes it does add up to the overall dimension.  

 

The LISP would need to be able to add up the amount displayed instead of the actual value of the dimension, as well as preferably any text override. So if i override the text in the 11 13/16" dimension to 11 3/4", the two dimensions would then add up to 2'10 7/8". Preferably the total would display in the command line. 

0 Likes
Accepted solutions (2)
10,804 Views
25 Replies
Replies (25)
Message 21 of 26

LoganAC34
Advocate
Advocate
Accepted solution

That worked! Though, i had to replace:

(rtos ; then -- measured distance as scaled & [if] rounded in display 
    mea ; measurement 
    (cdr (assoc 270 sdata)); mode
    (cdr (assoc 271 sdata)); precision 
)

With this: 

(rtos ; then -- measured distance as scaled & [if] rounded in display 
    mea ; measurement 
    5 ; mode 
    (cdr (assoc 271 sdata)); precision 
)

And then I added this further down in the code: 

(strcat "\nSum of displayed distances = " 
    (rtos sum 5 prec) 
    " OR " 
    (rtos sum 4 prec) 
    "." 
)

so it would match my dimension style mode format, and this also allows it work on millimeters. I kept the mode 4 so you could also using it on architectural dimensions. If you want to clean up or improve on how I made changes you can, though you don't need to, this works good enough for me. Thanks for taking the time to do this for me.

0 Likes
Message 22 of 26

Anonymous
Not applicable

Hi, I came across this LISP routine and was wondering if there is a way to make the following happen. Once you've executed the command its prompts "Sum of displayed distances" in the command line. Is it possible to make this where it will prompt "Square Footage" and will multiply whatever the total linear foot is by 15.167' ?

0 Likes
Message 23 of 26

LoganAC34
Advocate
Advocate
(defun C:DDVS ; = Dimension Displayed Value Sum
  (/ sum ss n dim mea ddata sdata disp prec)
  (setq sum 0.0); initial value to add to
  (prompt "\nTo add displayed values of Dimensions,")
  (if (setq ss (ssget '((0 . "DIMENSION"))))
    (progn ; then
      (repeat (setq n (sslength ss))
        (setq
          dim (ssname ss (setq n (1- n)))
          mea (cdr (assoc 42 (setq ddata (entget dim)))); measured value
          sdata (tblsearch "dimstyle" (cdr (assoc 3 ddata))); Style's data
          disp ; displayed value
            (if (member '(1 . "") ddata); no override of content?
              (rtos mea 5
                (cdr (assoc 271 sdata)); precision
              ); rtos
              (cdr (assoc 1 ddata)); else -- use override value
            ); if & disp
          prec (max (cond (prec) (0)) (cdr (assoc 271 sdata)))
          sum (+ sum (distof disp)); [decimal/real-number units]
        ); setq
      ); repeat
      (prompt
        (strcat
          "\nSum of displayed distances = " (rtos sum 5 prec) " OR " (rtos sum 4 prec) "."
          "\nSquare footage = " 
        ); strcat
      ); prompt
      (princ (/(* sum 182.004) 144)); multiply sum by 182.004" (or 15.167') to get square inches, and then convert to square footage
      (prompt (strcat "sq.ft"))
    ); progn
    (prompt "\nNo Dimensions selected."); else
  ); if
  (princ)
); defun

Try this. (minimally tested) I simply added what is in green.

This takes the sum of the dimension text and multiplies it by 182.004" (15.167') then converts it from square inches to square feet. 

If you want to change what the sum is multiplied by, you could either add a a command line prompt for the user to enter a value or you can just change it in the code what is in red. The number in read has to be in inches. 

0 Likes
Message 24 of 26

Anonymous
Not applicable

It worked great, thanks for your help.

0 Likes
Message 25 of 26

Anonymous
Not applicable

dear sir,

 

i want same lisp for sum in mm

 

please help

0 Likes
Message 26 of 26

dlanorh
Advisor
Advisor

Welcome to the Autodesk Forums 😁

 

Are your dimensions in millimetres or metres?

I am not one of the robots you're looking for

0 Likes