CADLisp Tools

Data Extraction

Cable/Route Length AutoLISP routine

Total selected route polylines and apply an optional allowance percentage. Download the .LSP source below and run the CABLELEN command after loading it.

⌘ CABLELENv1.0.0IntermediateUpdated Sep 18, 2026

What it does

Cable/Route Length with the CABLELEN AutoLISP command

Sums selected polyline paths and reports both measured route length and an allowance-adjusted cable length.

AutoLISP command
CABLELEN
Difficulty
Intermediate

Applicable disciplines

CAD workflows that use this routine

Requirements and compatibility

What it needs

AutoLISPVisual LISP

Software rows marked “Not tested” are not compatibility claims. Test the routine in a copy of your drawing and CAD version.

Downloadable source code

Review the cable-route-length.lsp AutoLISP code

cable-route-length.lspAUTOLISP
;; CADLisp Tools - Cable/Route Length
(vl-load-com)

(defun ct-cl:polyline-length (ent / data end flags result)
  (setq data (and ent (entget ent)))
  (if (and data
           (or (= (cdr (assoc 0 data)) "LWPOLYLINE")
               (and (= (cdr (assoc 0 data)) "POLYLINE")
                    (setq flags (cdr (assoc 70 data)))
                    (= 0 (logand flags 80))))
           (not (vl-catch-all-error-p
                  (setq end (vl-catch-all-apply 'vlax-curve-getEndParam (list ent)))))
           (not (vl-catch-all-error-p
                  (setq result (vl-catch-all-apply 'vlax-curve-getDistAtParam (list ent end))))))
    result))

(defun c:CABLELEN (/ allowance adjusted ent i length skipped ss total)
  (initget 4)
  (setq allowance (getreal "\nAllowance percent <0>: "))
  (if (null allowance) (setq allowance 0.0))
  (prompt "\nSelect route polylines: ")
  (if (setq ss (ssget '((0 . "LWPOLYLINE,POLYLINE"))))
    (progn
      (setq total 0.0 skipped 0)
      (repeat (setq i (sslength ss))
        (setq ent (ssname ss (setq i (1- i))) length (ct-cl:polyline-length ent))
        (if length
          (setq total (+ total length))
          (setq skipped (1+ skipped))))
      (setq adjusted (* total (+ 1.0 (/ allowance 100.0))))
      (prompt (strcat "\nMeasured: " (rtos total 2 3)
                      "; with allowance: " (rtos adjusted 2 3)
                      "; skipped: " (itoa skipped))))
    (prompt "\nNo route polylines selected."))
  (princ))

Setup

How to install the cable-route-length.lsp file

  1. 1Download and review the source code.
  2. 2Load the .lsp file with APPLOAD in a copy of a drawing.
  3. 3Keep the routine session-only until it has been tested for your CAD version and standards.

Command workflow

How to run the CABLELEN command

  1. 1Run CABLELEN.
  2. 2Enter a non-negative allowance percentage.
  3. 3Select route polylines and press Enter.

Worked example

Example: Estimate cable with 10 percent allowance.

  1. Run CABLELEN.
  2. Enter 10.
  3. Select the route.
Expected result

Measured and adjusted lengths are printed.

Read before use

Notes and limitations

  • Does not account for vertical drops unless represented in polyline geometry.
  • Does not convert drawing units.
  • Not manually CAD-tested.

Version history

Changelog

v1.0.0Sep 18, 2026Initial route total with percentage allowance.

Keep automating

Related tools

Data Extraction4 disciplines

Pipeline Length by Layer

Summarize selected polyline length totals grouped by layer.

⌘ PIPELENIntermediateCAD support: not tested
Updated Sep 18, 2026VIEW TOOL →
Geometry & Polylines4 disciplines

Station/Chainage Along Polyline

Report distance along a selected polyline to a picked location.

⌘ CHAINAGEIntermediateCAD support: not tested
Updated Sep 18, 2026VIEW TOOL →
Geometry & Polylines6 disciplines

Total Polyline Length

Calculate the combined length of selected 2D and legacy polylines.

⌘ TOTPLENBeginnerCAD support: not tested
Updated Sep 18, 2026VIEW TOOL →