bagulhodoido Posted July 7, 2010 Posted July 7, 2010 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. Quote
Lee Mac Posted July 7, 2010 Posted July 7, 2010 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)) ) ) Quote
alanjt Posted July 7, 2010 Posted July 7, 2010 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. Quote
Lee Mac Posted July 7, 2010 Posted July 7, 2010 Yeah, the downfall with Angular is that the Field displays it in Rads... Quote
alanjt Posted July 7, 2010 Posted July 7, 2010 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. Quote
Lee Mac Posted July 7, 2010 Posted July 7, 2010 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 Quote
alanjt Posted July 7, 2010 Posted July 7, 2010 OK, I'll leave that to the OP Nevermind. I just wanted yo to be aware. Quote
Lee Mac Posted July 7, 2010 Posted July 7, 2010 Nevermind. I just wanted yo to be aware. Thanks Quote
bagulhodoido Posted July 13, 2010 Author Posted July 13, 2010 Thank you guys! Exactly as needed! Quote
manori Posted November 29, 2010 Posted November 29, 2010 its saving my time.... thankyou very much...... Quote
rameshaxis Posted January 27, 2012 Posted January 27, 2012 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. Quote
rameshaxis Posted January 27, 2012 Posted January 27, 2012 Dear Mr Alan, I am very sorry to say, It is not working in Autocad2008. Quote
rameshaxis Posted February 13, 2012 Posted February 13, 2012 Thanks Mr Alanjt, I'am searching for this from longtime.It is very useful to me. Quote
alanjt Posted February 13, 2012 Posted February 13, 2012 Thanks Mr Alanjt, I'am searching for this from longtime.It is very useful to me. You're welcome. 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.