Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
MatthewB80097
Posts: 58
Registered: ‎11-01-2010
Message 1 of 3 (3,735 Views)

List total length of polylines - Lisp query

3735 Views, 2 Replies
07-30-2012 08:16 AM

Does anyone know where I can obtain a freeware lisp routine that lists the lengths of all the polylines on a specific layer or within a selection set? I want to avoid list if possible as there are rather a lot of polylines!

*Expert Elite*
Kent1Cooper
Posts: 5,871
Registered: ‎09-13-2004
Message 2 of 3 (3,728 Views)

Re: List total length of polylines - Lisp query

07-30-2012 09:52 AM in reply to: MatthewB80097

MatthewB80097 wrote:

Does anyone know where I can obtain a freeware lisp routine that lists the lengths of all the polylines on a specific layer or within a selection set? ....


You can no doubt find many routines on the Discussion Group that will do something or other to all Polylines in a selection set, and perhaps to all those on a certain Layer.  As for finding the lengths of them all, there are several approaches you can take:

 

(vl-load-com) if needed, then with the entity name saved in the 'path' variable....
 

(vlax-curve-getDistAtPoint path (vlax-curve-getEndPoint path)) returns 0 if it's closed, so you probably shouldn't use that [unless you would always be deailing only with open Polylines].

 
(vla-get-length (vlax-ename->vla-object path)) gives it for Lines and Polylines, so though it does NOT give it for Arcs or Circles or Ellipses or Splines, in this case it should be fine.

 
(vlax-curve-getDistAtParam path (vlax-curve-getEndParam path)) returns the length of any path type, open or closed, so it would also work, though it's longer than the previous one.

 

As to output, what do you mean by "lists the lengths"?  Just displays them at the Command: prompt line, or saves them into a list as a variable so you can do something with them, or writes them to a file, or....?

Kent Cooper
Valued Contributor
MatthewB80097
Posts: 58
Registered: ‎11-01-2010
Message 3 of 3 (3,688 Views)

Re: List total length of polylines - Lisp query

07-31-2012 02:07 AM in reply to: MatthewB80097

Thanks all, however found tschau answers my query on this thread...

 

http://forums.autodesk.com/t5/AutoCAD-2010/how-to-get-the-total-distance-lenght/td-p/2737919

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.