Print Page | Close Window

MULTIPLE LINE LENGTHS SUMMATION

Printed From: CAD Forum
Category: EN
Forum Name: AutoCAD
Forum Description: Discussion about AutoCAD and AutoCAD LT, viewers, DWG and DWF formats, Design Review, AutoCAD 360, add-ons
URL: https://www.cadforum.cz/forum_en/forum_posts.asp?TID=11814
Printed Date: 17.Apr.2026 at 17:01


Topic: MULTIPLE LINE LENGTHS SUMMATION
Posted By: Ikenna
Subject: MULTIPLE LINE LENGTHS SUMMATION
Date Posted: 13.May.2016 at 15:36
Halo Forum Members, good afternoon.
 
Please I need to know if there is a single command I can use to get the total summation of the lengths of different, separate lines. For example, if I have five separate lines measuring 5,10, 10, 5 and 3 meters each. My question now is: Is there a way I can select the five lines at once and issue a command and the AutoCAD application will simply give me the total lengths as 33 metres!
Thanks.



Replies:
Posted By: John Connor
Date Posted: 13.May.2016 at 15:44
There are lisp routines that will give you the total length of a series of lines.  One of them is called TLEN.lsp and it is from Tee Square Graphics.  You can also look for Lee Mac's Total Length program; it's on his website.


-------------
"Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."

<<AutoCAD 2015>>



Posted By: Kent Cooper
Date Posted: 23.May.2016 at 22:20
http://cadtips.cadalyst.com/2d-operations/length-linear-objects" rel="nofollow - Here 's another one.  Some Searching will probably find several others.


Posted By: Ikenna
Date Posted: 27.May.2016 at 11:39
Thanks so much John. Let me check it out.


Posted By: Ikenna
Date Posted: 27.May.2016 at 11:58
Thanks very much Kent. I just tried this method and it worked! But the issue is that it gives the summations in feet and inches. Secondly, it doesn't select arcs for summation.


Posted By: John Connor
Date Posted: 27.May.2016 at 12:14
You should have tried Lee Mac's program.

http://www.lee-mac.com/totallengthandarea.html


-------------
"Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."

<<AutoCAD 2015>>



Posted By: Ikenna
Date Posted: 27.May.2016 at 14:35
John, thanks very much. I tried it and it worked perfectly. Everything was calculated - lines and arcs!, and the summation was given in metres!! Thanks again.Smile


Posted By: Ikenna
Date Posted: 27.May.2016 at 14:53
Sorry, I meant 'summation was given in metric units'. Yes, I got it in millimetres.


Posted By: John Connor
Date Posted: 27.May.2016 at 15:09
You're welcomed.  Glad to hear you found something that suits your needs.


-------------
"Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."

<<AutoCAD 2015>>



Posted By: Kent Cooper
Date Posted: 27.May.2016 at 16:51
Originally posted by Ikenna Ikenna wrote:

... the issue is that it gives the summations in feet and inches. Secondly, it doesn't select arcs for summation.
It's odd that the description at the linked page mentions Arcs, but in fact the routine isn't written to accept them.  You can change that to include them, and far more entity types, by changing this line:
  (setq sset (ssget '((0 . "LINE,LWPOLYLINE")))
to this:
 
  (setq sset (ssget '((0 . "LINE,*POLYLINE,ARC,CIRCLE,ELLIPSE,SPLINE")))
 
BUT since not all of those entity types have the same "length" VLA property [some have one but under a different name], you would also have to change this line:
 
   (vla-get-length (vlax-ename->vla-object (ssname sset num)))
 
to this:
 
   (vlax-curve-getDistAtParam (setq ent (ssname sset num)) (vlax-curve-getEndParam ent))
 
which will find the length of any (vlax-curve-...)-compatible entity, open or closed.
 
And you can have it report in whatever Units you like.  Change this:
 
     llen (rtos llen 4)
which reports in Architectural units [the 4] to just:
 
     llen (rtos llen)
 
if you want it to report in whatever your current Units and Precision settings are, or use other values for units and precision in the (rtos) function, to suit your requirements.
[Also, I would change the (alert) to use a word like "object" instead of "line."]


Posted By: jmontesmx
Date Posted: 27.May.2016 at 20:15
This can help you too, I ask the same thing some time ago
http://www.cadtom.com/Arquivo/AutoLISP/Sumper.zip" rel="nofollow -


Posted By: jmontesmx
Date Posted: 27.May.2016 at 20:18

;;; J.A.
;;; http://www.jorgeanjos.com" rel="nofollow - www.jorgeanjos.com
;;; http://www.cadtom.com" rel="nofollow - www.cadtom.com

;;; VER 1.0 - 2002-09-02
;;; VER 2.0 - 2009-08-28

;;; Begin Sumper.lsp - Application to calculate the length of selected objects

(defun C:SUMPER (/   VADEC    VALLPRC  GLG      SSLEN    TPNAM
   LGNAM   LGSTOTAL LGTOTAL  TERM     TXSTOTAL TXTOTAL
   TESTE
  )

  (setq VADEC (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  (command "undo" "begin")
  (setq VALLPRC  (getvar "luprec")
 LGSTOTAL 0.0
 TERM  0
  )
  (mlen)
  (while (/= TERM nil)
    (progn
      (mlen)
    )
  )
  (setq TXTOTAL (rtos LGSTOTAL 2 VALLPRC))
  (princ "\n»» Total = ")
  (princ TXTOTAL)
  (command "undo" "end")
  (setvar "cmdecho" VADEC)
)

;;;
;;;

(defun MLEN ()

  (princ "\n»» Select entities to calculate the length: \n")
  (terpri)
  (setq GLG (ssget))
  (if GLG
    (progn
      (setq SSLEN (sslength GLG))
      (while (> SSLEN 0)
 (setq TPNAM  (ssname GLG (setq SSLEN (1- SSLEN)))
       ENTGT  (entget TPNAM)
       ENTLAY (cdr (assoc 0 ENTGT))
 )
 (if (equal ENTLAY "LINE")
   (setq TESTE 1)
 )
 (if (equal ENTLAY "POLYLINE")
   (setq TESTE 1)
 )
 (if (equal ENTLAY "LWPOLYLINE")
   (setq TESTE 1)
 )
 (if (equal ENTLAY "CIRCLE")
   (setq TESTE 1)
 )
 (if (equal ENTLAY "ARC")
   (setq TESTE 1)
 )
 (if (equal ENTLAY "SPLINE")
   (setq TESTE 1)
 )
 (if (equal ENTLAY "ELLIPSE")
   (setq TESTE 1)
 )
 (if (equal TESTE 1)
   (progn
     (command "lengthen" TPNAM "")
     (setq LGTPNAM  (getvar "PERIMETER")
    LGSTOTAL (+ LGTPNAM LGSTOTAL)
    TESTE    0
     )
   )
 )
      )
    )
    (princ "\n»» No entity was selected: \n")
  )
  (setq TXSTOTAL (rtos LGSTOTAL 2 VALLPRC))
  (initget "Add")
  (princ "\n»» Subtotal = ")
  (princ TXSTOTAL)
  (terpri)
  (setq TERM
  (getkword " [A] Add more entities or <Enter> to finish:  ")
  )
)
(princ "\n»» Type 'SUMPER' to start application ")

     ; END Sumper.lsp



Posted By: Vladimir Michl
Date Posted: 28.May.2016 at 11:48
See also AddLen:
http://www.cadforum.cz/cadforum_en/total-length-of-lines-in-a-drawing-by-layer-tip7005" rel="nofollow - http://www.cadforum.cz/cadforum_en/total-length-of-lines-in-a-drawing-by-layer-tip7005


-------------
Vladimir Michl (moderator)
ARKANCE - https://arkance.world" rel="nofollow - https://arkance.world - Autodesk Platinum Partner



Print Page | Close Window