Snownut Posted February 5, 2011 Posted February 5, 2011 I am trying to retrieve all measurement data from a single dimstyle ie; add all measurements for each dimension of a single dimstyle. I would like to do this in LISP and then use the results as a single variable. Any ideas? Thanks in advance for all assistance rendered. Bruce Quote
Smirnoff Posted February 5, 2011 Posted February 5, 2011 All measurements in the oLst variable. (defun c:test(/ sDim dSet dLst dSty oLst) (if(and (setq sDim(entsel "\nPick sample dimension > ")) (equal '(0 . "DIMENSION")(assoc 0(entget(car sDim)))) (setq dSty(assoc 3(entget(car sDim)))) ); end and (progn (setq dSet(ssget "_X" (list '(0 . "DIMENSION") dSty)) dLst(vl-remove-if 'listp(mapcar 'cadr(ssnamex dSet))) ); end setq (foreach d dLst (setq oLst(append oLst(list(cdr(assoc 42(entget d)))))) ); end foreach ); end progn (progn "\n<!> This isn't dimension <!> ") ); end if (princ "\n")(textscr) oLst ); end of c:test Quote
Smirnoff Posted February 5, 2011 Posted February 5, 2011 add all measurements for each dimension of a single dimstyle Ок. Sum length of all dimensions of dimstyle selected. (defun c:test(/ sDim dSet dLst dSty oLst) (if(and (setq sDim(entsel "\nPick sample dimension > ")) (equal '(0 . "DIMENSION")(assoc 0(entget(car sDim)))) (setq dSty(assoc 3(entget(car sDim)))) ); end and (progn (setq dSet(ssget "_X" (list '(0 . "DIMENSION") dSty)) dLst(vl-remove-if 'listp(mapcar 'cadr(ssnamex dSet))) ); end setq (foreach d dLst (setq oLst(append oLst(list(cdr(assoc 42(entget d)))))) ); end foreach ); end progn (progn "\n<!> This isn't dimension <!> ") ); end if (princ(strcat "\nSum length for '" (cdr dSty) "' dimstyle: " (rtos(apply '+ oLst)) ); end strcat ); end princ (princ) ); end of c:test Quote
Snownut Posted February 5, 2011 Author Posted February 5, 2011 Smirnoff, that works perfectly, however I know the name of the Dimstyle and would like to not select a dimension for this to work. I would like to enter the dimstyle name as a variable ie; (setq variable "TtoTSLine") where "TtoTSLine" is the name of the dimstyle. I have been playing around with your code to have it function this way but have not been successful. Thank you for what you have provided her. Bruce Quote
Smirnoff Posted February 5, 2011 Posted February 5, 2011 This is what you need? (defun c:test(/ dSet dLst dSty oLst) [color="#0000ff"](setq dSty "TtoTSLine")[/color] (if(setq dSet(ssget "_X" (list '(0 . "DIMENSION")(cons 3 dSty )))) (progn (setq dLst(vl-remove-if 'listp(mapcar 'cadr(ssnamex dSet))) ); end setq (foreach d dLst (setq oLst(append oLst(list(cdr(assoc 42(entget d)))))) ); end foreach (princ(strcat "\nSum length for '" dSty "' dimstyle: " (rtos(apply '+ oLst)) ); end strcat ); end princ ); end progn (princ "\n<!> No dimensions found <!> ") ); end if (princ) ); end of c:test Quote
Snownut Posted February 6, 2011 Author Posted February 6, 2011 Smirnoff, that works perfectly, thank you very much for your efforts. Bruce Quote
Smirnoff Posted February 6, 2011 Posted February 6, 2011 No problem. This is only a small exercise of neurons in the brain. Quote
alanjt Posted February 7, 2011 Posted February 7, 2011 Be careful about DimRadial and DimAngular. Radial may be acceptable (depending on one's situation), but Angular will return the angle in radians. Here's what I use... (defun c:DimSum (/ ss) ;; Alan J. Thompson (if (setq ss (ssget '((0 . "DIMENSION")))) ((lambda (i total / e d) (while (setq e (ssname ss (setq i (1+ i)))) (or (wcmatch (cdr (assoc 100 (reverse (setq d (entget e))))) "*Angular*,*Radial*") (setq total (+ total (cdr (assoc 42 d)))) ) ) (or (zerop total) (alert (princ (strcat "\nTotal: " (rtos total))))) ) -1 0. ) ) (princ) ) 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.