How to calculate the total length of multiple lines

veloster
Participant
Participant

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!

Reply
Accepted solutions (2)
750,084 Views
74 Replies
Replies (74)

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

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

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

CADDVV
Enthusiast
Enthusiast
Good to know, thank you!
0 Likes

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

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. 

james1973622103
Explorer
Explorer

exactly what I'm looking for, Thanks you!

0 Likes

kmatsuoka
Observer
Observer

Thank you. this is a great way

0 Likes

CADDVV
Enthusiast
Enthusiast

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

 

Thanks!!

0 Likes

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

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 

muhammad_tahirSA3UH
Community Visitor
Community Visitor
Thanks mate.
0 Likes

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

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


ealexanderK6PT2
Community Visitor
Community Visitor

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