Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

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

List total length of polylines - Lisp query

2871 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,266
Registered: ‎09-13-2004
Message 2 of 3 (2,864 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: 56
Registered: ‎11-01-2010
Message 3 of 3 (2,824 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community