Jump to content

Recommended Posts

Posted

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

Posted

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

Posted
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

Posted

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

Posted

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

Posted

Smirnoff, that works perfectly, thank you very much for your efforts.

 

Bruce

Posted

No problem. This is only a small exercise of neurons in the brain. :D

Posted

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

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