I need to add up the total length of all of the contours in an area. The contours are LDD contour objects. Does anyone know of a routine that will add the lengths of selected contours or polylines?
|
I need to add up the total length of all of the contours in an area. The contours are LDD contour objects. Does anyone know of a routine that will add the lengths of selected contours or polylines?
Hi
Below routine is from an old LISP Guild post by Stig Madsen -
Code:(defun C:PLINELEN (/ ent sset obj len sum layer a) (setvar "ERRNO" 0) (while (and (not (setq ent (car (entsel "Select object on layer: ")))) (/= (getvar "ERRNO") 52) ) ) (cond ((and ent (setq sset (ssget "X" (list '(0 . "LWPOLYLINE") (cons 8 (setq layer (cdr (assoc 8 (entget ent))))) ) ) ) ) (setq a 0 sum 0 ) (repeat (sslength sset) (setq obj (vlax-ename->vla-object (ssname sset a)) len (vlax-curve-getDistAtParam obj (- (vlax-curve-getEndParam obj) (vlax-curve-getStartParam obj) ) ) sum (+ sum len) ) (setq a (1+ a)) ) (princ (strcat "\nTotal length of " (itoa a) (if (= a 1) " pline on layer " " plines on layer " ) layer ": " (rtos sum) ) ) ) (T (princ "\nNo plines found")) ) (princ) )
OR
Check out something like the following -
[size=2]]CADalyst Get the Code August 1999 - Pline Lengths
Have a good one, Mike
Last edited by Mike.Perry; 2004-11-04 at 11:45 AM. Reason: Correct formatting.
You say LDD contour obects, if I take this to suggest
that you have Land, and MAP at your disposal
just use a MAP query of those objects, and set it to
write a report of all the objects lengths in a comma delimited file
and add them in Excel.
Last edited by mjfarrell; 2004-09-17 at 06:02 PM.
I copied the text to a text file, saved with a .lsp extension and used APPLOAD to load the application, however, I keep getting "Unknown command" ? when I type the new command name on the command line?.
Using AutoCAD 2004
Any ideas?
Hi
Worked for me (just tested a few moments ago).
* Copy & Paste Code into an ASCII text file (eg NotePad)
* SaveAs PlineLen.lsp
* Load into AutoCAD
* At AutoCAD Command Line type PlineLen
Have a good one, Mike
Just out of curiosity, why do you want to do that?Originally Posted by jbenway
It's grt...... I was about to create a lisp on my own... but i got a flash to check any post available related to my need....and I found this exactly meets my requirement... It saved me lot of time and effort..... Thanks for the creator......