Jump to content

Recommended Posts

Posted

Hi guys!

 

I have searched everywhere to a lisp that could sum all the selected dimension values.

 

I already got the lisp that sums all the lines and/or polylines, yet, It doesn't work this time.

 

Does anyone know a lisp that coul do that? Sum the selected dimension entities values?

 

Thanks in advance.

Posted

As a quick modification of an old area lisp I wrote, just using the measurement property of a dimension:

 

(defun c:Dims2Field ( / *error* spc doc pt uFlag ss ids )
 (vl-load-com)
 ;; © Lee Mac 2010

 (defun *error* ( msg )
   (and uFlag (vla-EndUndomark doc))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ)
 )

 (setq spc
   (if
     (or
       (eq AcModelSpace
         (vla-get-ActiveSpace
           (setq doc
             (vla-get-ActiveDocument
               (vlax-get-acad-object)
             )
           )
         )
       )
       (eq :vlax-true (vla-get-MSpace doc))
     )
     (vla-get-ModelSpace doc)
     (vla-get-PaperSpace doc)
   )
 )  

 (if (and (ssget '((0 . "*DIMENSION")))
          (setq pt (getpoint "\nPick Point for Field: ")))
   (progn
     (setq uFlag (not (vla-StartUndoMark doc)))
     
     (vlax-for obj (setq ss (vla-get-ActiveSelectionSet doc))
       (setq Ids
         (cons (GetObjectID obj doc) Ids)
       )
     )
     (vla-delete ss)

     (vla-AddMText spc (vlax-3D-point pt) 0.

       (if (= 1 (length Ids))
         (strcat "%<\\AcObjProp Object(%<\\_ObjId " (car Ids) ">%).Measurement \\f \"%lu6\">%")
         (strcat "%<\\AcExpr"
           (lst->str Ids " %<\\AcObjProp Object(%<\\_ObjId " ">%).Measurement >% +")
           ">%).Measurement >% \\f \"%lu6\">%"
         )
       )
     )
     
     (setq uFlag (vla-EndUndomark doc))
   )
 )
 (princ)
)

(defun lst->str ( lst d1 d2 )
 ;; © Lee Mac 2010
 (if (cdr lst)
   (strcat d1 (car lst) d2 (lst->str (cdr lst) d1 d2))
   (strcat d1 (car lst))
 )
)

(defun GetObjectID ( obj doc )
 ;; © Lee Mac 2010
 (if
   (eq "X64"
     (strcase
       (getenv "PROCESSOR_ARCHITECTURE")
     )
   )
   (vlax-invoke-method
     (vla-get-Utility doc) 'GetObjectIdString obj :vlax-false
   )
   (itoa (vla-get-Objectid obj))
 )
)

Posted

I wrote this not long ago...

 

(defun c:DimSum (/ ss)
 ;; Alan J. Thompson
 (if (setq ss (ssget '((0 . "DIMENSION"))))
   ((lambda (v)
      (vlax-for x (setq ss (vla-get-activeselectionset
                             (cond (*AcadDoc*)
                                   ((setq *AcadDoc* (vla-get-activedocument
                                                      (vlax-get-acad-object)
                                                    )
                                    )
                                   )
                             )
                           )
                  )
        (or (wcmatch (vla-get-objectname x) "*Angular*") (setq v (+ v (vla-get-measurement x))))
      )
      (vla-delete ss)
      (or (zerop v) (alert (strcat "Total: " (rtos v))))
    )
     0.
   )
 )
 (princ)
)

Lee, know that angular dimensions have the measurement property too. My original was a lot simpler until was curious if it would crash if I selected one.

Posted

Yeah, the downfall with Angular is that the Field displays it in Rads...

Posted
Yeah, the downfall with Angular is that the Field displays it in Rads...

Right, but if one is calculating the total sum of dimensions, an angular dimension isn't a length value that one would want. My point is that it should be filtered out.

Posted
Right, but if one is calculating the total sum of dimensions, an angular dimension isn't a length value that one would want. My point is that it should be filtered out.

 

OK, I'll leave that to the OP :P

Posted
OK, I'll leave that to the OP :P
Nevermind. I just wanted yo to be aware.
Posted

Thank you guys! Exactly as needed!

  • 4 months later...
  • 1 year later...
Posted

Dear Mr Lee,

 

Thanks for the code. but I am very sorry to say that it is showing in hatch model and too small. Plz improve it.

 

 

Sorry for my poor language.

Posted

Dear Mr Alan,

 

I am very sorry to say, It is not working in Autocad2008.

  • 3 weeks later...
Posted

Thanks Mr Alanjt, I'am searching for this from longtime.It is very useful to me.:D

Posted
Thanks Mr Alanjt, I'am searching for this from longtime.It is very useful to me.:D

You're welcome.

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