PDA

View Full Version : Total polyline length



jbenway
2004-09-17, 02:39 PM
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?

Mike.Perry
2004-09-17, 03:59 PM
Hi

Below routine is from an old LISP Guild post by Stig Madsen -


(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 (http://new.cadalyst.com/code/browseyear.cfm?fullyear=1999#8[/size)

Have a good one, Mike

mjfarrell
2004-09-17, 05:59 PM
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.

nigel.chesworth
2005-02-28, 01:50 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?

Mike.Perry
2005-02-28, 02:32 PM
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

sinc
2005-03-01, 03:27 PM
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?
Just out of curiosity, why do you want to do that?

vinceneb9575
2011-10-18, 06:08 AM
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......