Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to calculate the total length of multiple lines

74 REPLIES 74
SOLVED
Reply
Message 1 of 75
veloster
750070 Views, 74 Replies

How to calculate the total length of multiple lines

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!

Tags (1)
74 REPLIES 74
Message 61 of 75


@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
Message 62 of 75
israel.shawEKTNS
in reply to: veloster

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 

Message 63 of 75


@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
Message 64 of 75
CADDVV
in reply to: israel.shawEKTNS

Good to know, thank you!
Message 65 of 75
braudpat
in reply to: Kent1Cooper

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


Message 66 of 75
jebinabraham
in reply to: veloster

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 75
james1973622103
in reply to: Anonymous

exactly what I'm looking for, Thanks you!

Message 68 of 75
kmatsuoka
in reply to: jebinabraham

Thank you. this is a great way

Message 69 of 75
CADDVV
in reply to: nestly2

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

 

Thanks!!

Message 70 of 75
CADDVV
in reply to: nestly2

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

Message 71 of 75
pendean
in reply to: CADDVV


@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 75

Thanks mate.
Message 73 of 75
OmniCardoso
in reply to: braudpat

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

Message 74 of 75
braudpat
in reply to: OmniCardoso

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 75

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. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report