How to calculate the total length of multiple lines

How to calculate the total length of multiple lines

veloster
Participant Participant
797,970 Views
77 Replies
Message 1 of 78

How to calculate the total length of multiple lines

veloster
Participant
Participant

Hi!
I would like to know if it's possible to have the total length of different lines by selecting them in a drawing?
Those lines are all separated and it will take forever to do it manually on a calculator 🙂
Thx!

Accepted solutions (2)
797,971 Views
77 Replies
Replies (77)
Message 61 of 78

Kent1Cooper
Consultant
Consultant

@israel.shawEKTNS wrote:

There are some errors with the .lsp. It was able to work well for most of the polylines in my drawing. But for some, it returns a value of 0. The length shows up in the properties panel the same way as the other polylines, but the app doesn't seem to see these ones. 


Are any closed Polylines?  If so, one way of getting their length with (vlax-curve-...) functions returns zero, but there's another way that doesn't.  Which code out of sixty-some Messages and links are you using?

Kent Cooper, AIA
0 Likes
Message 62 of 78

israel.shawEKTNS
Explorer
Explorer

I was using the tlenght by braudpat in message 5. But it turns out the ones that weren't working were 2D polylines. It's an easy conversion, so I'm good now. But it's worth noting the lsp doesn't work for 2D polylines 

0 Likes
Message 63 of 78

Kent1Cooper
Consultant
Consultant
Accepted solution

@israel.shawEKTNS wrote:

I was using the tlenght by braudpat in message 5. But it turns out the ones that weren't working were 2D polylines. It's an easy conversion, so I'm good now. But it's worth noting the lsp doesn't work for 2D polylines 


It just left out the term for those.  But a lot of them can be combined into the same length determination.  You can change this much:

 

((member (vla-get-objectname ent) '("AcDbLine" "AcDb3dPolyline" "AcDbPolyline"))
(setq di (+ di (vla-get-length ent)))
)
((eq (vla-get-objectname ent) "AcDbArc")
(setq di (+ di (vla-get-arclength ent)))
)
((eq (vla-get-objectname ent) "AcDbCircle")
(setq di (+ di (vla-get-circumference ent)))
)
((member (vla-get-objectname ent) '("AcDbSpline" "AcDbEllipse"))
(setq di (+ di (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent))))
)

 

to just this:

 

((member (vla-get-objectname ent)

  '("AcDbLine" "AcDb3dPolyline" "AcDb2dPolyline" "AcDbPolyline"

    "AcDbArc" "AcDbCircle" "AcDbSpline" "AcDbEllipse"))
  (setq di (+ di (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent))))
)

 

Or:

 

((wcmatch (substr (vla-get-objectname ent) 5)

  "Line,3dPolyline,2dPolyline,Polyline,Arc,Circle,Spline,Ellipse")
  (setq di (+ di (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent))))
)

Kent Cooper, AIA
0 Likes
Message 64 of 78

CADDVV
Enthusiast
Enthusiast
Good to know, thank you!
0 Likes
Message 65 of 78

braudpat
Mentor
Mentor

Hello@Kent1Cooper 

 

Thanks for the improvment !

 

Happy New Year, The Health, Bye, Patrice (The Old French EE Froggy)

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes
Message 66 of 78

jebinabraham
Explorer
Explorer

Select  the lines and enter DATAEXTRACTION, then window pops up. Select create new data extraction and click next. Enter file name for a new file n save it in your preferred location. Then click save and in next window select object in the current drawing and click the boton on right to it. Select the lines in your drawing. Click next. Click next again. On right in category unchecked all except geometry. In the left side unchecked all except length. Click next. Click next again. Select output data to. Xls. Select location n file name and it will b saved in excel file. Open that excel file n add all the lengths. 

Message 67 of 78

james1973622103
Explorer
Explorer

exactly what I'm looking for, Thanks you!

0 Likes
Message 68 of 78

kmatsuoka
Observer
Observer

Thank you. this is a great way

0 Likes
Message 69 of 78

CADDVV
Enthusiast
Enthusiast

Can you repost the lisp?  The link does not work or has been removed.

 

Thanks!!

0 Likes
Message 70 of 78

CADDVV
Enthusiast
Enthusiast

Is it possible to resend the link with the lisp? When I tried to use the link it no longer worked.

 

http://www.turvill.com/t2/free_stuff/tlen.lsp

0 Likes
Message 71 of 78

pendean
Community Legend
Community Legend

@CADDVV wrote:

Can you repost the lisp?  The link does not work or has been removed.

 

Thanks!!


https://www.google.com/search?q=tlen.lsp 

Message 72 of 78

muhammad_tahirSA3UH
Community Visitor
Community Visitor
Thanks mate.
0 Likes
Message 73 of 78

OmniCardoso
Contributor
Contributor

Hey there, I just downloaded this and when I run it, it says "The Total Length of the xx objects are : 0.000"
Any tips on why it's not working?

Thanks

0 Likes
Message 74 of 78

braudpat
Mentor
Mentor

Hello @OmniCardoso 

 

Please use this version of the LENGTH routine !

 

The Health, Bye, Patrice (The Old French EE Froggy)

 

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 75 of 78

ealexanderK6PT2
Observer
Observer

This should be bumped up to the #1 solution. I'm not anti LISP routine or anything but I feel like this solution will help people become better CAD users and not just solve a calculation problem. 

0 Likes
Message 76 of 78

sambathdesignerT7GCN
Community Visitor
Community Visitor

Dear sir
I had downloaded but I don't know how to install or where to copy to,
This the file name that I got, AntoniaPetrovaTotalLength.msi
Could you please give me the guide line,

 

Regards,

Sambath

0 Likes
Message 77 of 78

muhammad_tahirSA3UH
Community Visitor
Community Visitor

Download the totallength lisp command from google. 
Load it in your CAD and run it.

0 Likes
Message 78 of 78

Anonymous
Not applicable

Type command MEASUREGEOM. If your CAD version has this command then simply type T (total lenght) and then select objects with polygon. Result shall be shown in command line. Works for all types of lines.

0 Likes