(defun C:TLEN (/ ss tl n ent itm obj l) (setq ss (ssget) tl 0 n (1- (sslength ss))) (while (>= n 0) (setq ent (entget (setq itm (ssname ss n))) obj (cdr (assoc 0 ent)) l (cond ((= obj "LINE") (distance (cdr (assoc 10 ent)) (cdr (assoc 11 ent)))) ((= obj "ARC") (* (cdr (assoc 40 ent)) (if (minusp (setq l (- (cdr (assoc 51 ent)) (cdr (assoc 50 ent))))) (+ pi pi l) l))) ((or (= obj "CIRCLE") (= obj "SPLINE") (= obj "POLYLINE") (= obj "LWPOLYLINE") (= obj "ELLIPSE")) (command "_.area" "_o" itm) (getvar "perimeter")) (T 0) ) tl (+ tl l) n (1- n) ) ) (alert (strcat "Total length of selected objects is " (rtos tl))) (princ) )
If another routine uses TLEN , you may need to open the .lsp file in Notepad and rename the command (look for defun c:tlen ). Conclusion
Modern Autodesk releases feature strict script-loading security frameworks. Enter SECURELOAD directly into your command bar. Change the system variable variable from 1 to 0 .
This is another excellent LISP routine that explicitly supports a massive list of objects, including: LINE , POLYLINE , LWPOLYLINE , ARC , CIRCLE , ELLIPSE , SPLINE , MLINE , REGION , and MPOLYGON . autocad tlenlsp download work
Look for a more comprehensive total‑length script, such as Lee Mac’s “TotalLength” LISP, which handles a wider range of object types and uses more robust object‑property queries.
If you cannot get the legacy tlen.lsp to work, don’t fight it. Use AutoCAD’s built-in or a modern LISP:
There are three main ways to get the script working in your workspace: : (defun C:TLEN (/ ss tl n ent itm
Use an updated version of TLEN that directly queries the polyline’s length property through the Visual LISP vla-get-length method rather than relying on the AREA command. Many forum posts provide corrected code.
If the command is not recognized, consider these common issues:
AutoCAD, by design, lacks a native command to display the sum of lengths for a selection of disparate linear objects. While AutoCAD's AREA command can find the perimeter of a single polyline, it fails to aggregate the lengths of multiple, separate lines or arcs. This is a common hurdle across many design fields where such calculations are needed for walls, cables, pipes, or fences. Change the system variable variable from 1 to 0
In the fast-paced world of CAD design, efficiency is key. Engineers, architects, and drafters constantly seek tools that minimize repetitive tasks and accelerate the design process. One such hidden gem in the AutoCAD ecosystem is .
You can also add the line (load "tlen") to your acaddoc.lsp or acad.lsp file (create one if it does not exist) and place that file in one of AutoCAD’s support paths. This is a more traditional method that works across sessions.