• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
blog.draftsperson.net

blog.draftsperson.net

the art of technical drawing

blog.draftsperson.net

LENGTHTOTAG LISP: Put a Live Length Field Into an Attribute

August 3, 2026

LENGTHTOTAG pushes a length — or the sum of several lengths — into a block attribute as a live field. Select the objects to measure, pick the attribute, and it is populated with a field showing the total. Editing the geometry updates the attribute automatically.

What LengthToTag does

This is the companion to AREATOTAG, for anything measured by run rather than by area: pipe lengths, kerb runs, cable routes, fence lines.

Pick either the attribute itself or anywhere on its block. A block with one attribute uses it without asking; one with several offers a list. Set LengthToTag:Tag to a tag name — LENGTH, say — and that attribute is used automatically whenever the picked block has one.

How to use it

  1. Load the routine with APPLOAD, or put it on your support file search path.
  2. Type LENGTHTOTAG.
  3. Select the objects to measure.
  4. Pick the target attribute, or anywhere on the block containing it.
  5. Choose from the list if the block holds several attributes and no preset is configured.

How it works

A field must name the property it reads, and that name differs by object type:

Arc — ArcLength
Circle — Circumference
Line — Length
Polyline — Length

Asking a circle for its Length returns nothing at all — not an error, just an empty field. So the property is looked up from the object’s class name rather than assumed. That single lookup is what lets a mixed selection of lines, arcs and polylines sum correctly instead of silently dropping the arcs.

Notes and limits

  • The block must already have an attribute to write into. This populates one; it does not add one.
  • Constant attributes cannot hold a field — they live in the block definition rather than the insertion.
  • Deleting a measured object breaks the field, which then shows ####. On a check set that is useful: a broken tag is visible, a stale typed number is not.
  • The result is in drawing units.

Download and details

NameLengthToTag — write a length into a block attribute as a live field
DownloadLengthToTag.lsp — 13.9 KB, plain AutoLISP source. Downloads directly; no zip to unpack.
TypeAutoCAD AutoLISP routine
CommandLENGTHTOTAG
Requiresthe ActiveX layer (loaded automatically by the routine with vl-load-com); nothing extra — the dialog is written to a temporary file at run time and deleted again, so there is no .dcl to install.
Source size13.9 KB, 340 lines
Error handlingYes — a *error* handler restores every system variable it changed, on cancel as well as on error.
UndoThe whole operation is wrapped in a single undo group, so one U reverses all of it.
CompatibilityAutoCAD (any release with AutoLISP), BricsCAD, ZWCAD, GstarCAD, ProgeCAD and other IntelliCAD-based platforms. AutoCAD LT needs a LISP enabler. No .NET, no ObjectARX, no installer.
AuthorYZ, August 2026
LicenceFree to use, supplied “as is” with no warranty.

References

  • AREATOTAG LISP — the same job for areas rather than lengths
  • TAPE LISP — a one-off total at the command line instead of a field
  • FOLLOWON LISP — select the whole run before measuring it
  • More free AutoLISP routines on this site
  • Wisey’s Steel Shapes — free structural steel section drawing program

Filed Under: AutoLISP Routines

Primary Sidebar

Subscribe to our Youtube Channel

Post CAD drafting jobs on Freelancer.com. and get some free money to do this.

Categories

  • American Steel Industry (4)
  • AutoCAD Articles & Reference (30)
  • AutoCAD Bugs & Problems (19)
  • AutoCAD Tips (29)
  • AutoCAD Tutorials (54)
  • AutoLISP Routines (328)
  • AutoLISP Tutorials (15)
  • CAD Standards (7)
  • Civil 3D (7)
  • Civil Drafting (4)
  • Dimensions (2)
  • Drafting Funnies (71)
  • Drafting History (9)
  • Drafting Standards (84)
  • Electrical Drafting (2)
  • General IT reference (7)
  • Geometry (15)
  • GIS (2)
  • Hatch Patterns (12)
  • Office Life Hacks (3)
  • PT (1)
  • Revit Tutorials (54)
  • Steel Detailing (14)
  • Structural Drafting (26)
  • Technical Dictionary (61)
  • Useful Website Links (19)

Footer

Free downloads

  • Free AutoLISP routines
  • Free hatch patterns
  • SHX fonts & text styles
  • Numbering LISP collection
  • ISO 3098B font

Reference charts

  • AWS weld symbols chart
  • Steel detailing chart
  • Hole & slot sizes
  • Bolt edge distance
  • ANSI & ARCH paper sizes
  • How to fold an A1 drawing

Useful links

  • CAD blocks (DWG)
  • Revit families
  • structuraldrafter.com
  • cad-corner.com
  • About
  • Privacy policy

Provided for free with no warranty · Log in