• 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

DISTBEAR LISP: Label Line Distance and Bearing in AutoCAD

June 18, 2020

Last updated July 28, 2026

DISTBEAR labels lines with their length and bearing. You select one line or a whole boundary at once, and it writes a text item at the midpoint of each, rotated to sit parallel with the line, reading in the form 34.25 @ N45d0'0"E. It is a surveying and map-making tool: the quick way to annotate a traverse or a title boundary when you do not have a survey package driving the drawing.

The banner it prints on startup dates it: “Distance & Bearing, ver 1.2, (c)1990..94 Axsys Technology Ltd.” The help file that ships with it carries the same credit with a 1996 end date. The listing below records the author as Anon; the files themselves name Axsys Technology Ltd.

What it does in practice

After you make a selection, the routine filters it down to LINE entities only — it reports how many it found, so a crossing window over a busy drawing is safe. Anything else in the selection is discarded. Note that despite the listing mentioning polyline segments, the filter accepts plain lines only; a polyline boundary will need exploding first.

For each line it takes the start and end points from the entity, measures the distance between them and the angle from one to the other, and places a centred text item at the midpoint. Distance is written to two decimal places. The bearing is formatted with AutoCAD’s own angle conversion using whatever the AUNITS system variable is set to, at four decimal places of precision — so if you have AUNITS set to surveyor’s units you get proper quadrant bearings, and if you have it set to decimal degrees you get decimal degrees. Set AUNITS before you run it, not after.

Bearings are folded into the range 0 to 180 degrees: any angle over 180 has 180 subtracted from it. That means the label always reads in one direction regardless of which way the line was drawn, which is usually what you want on a boundary, but it does mean the text is not telling you the direction of travel.

Two quirks to expect

It finishes with an error message. The loop that steps through the lines runs one pass too many: after labelling the last line it asks the selection set for an item at index minus one, gets nothing back, and hands that nothing to the function that reads entity data. The routine’s error handler catches it and prints an error line. Every line still gets labelled correctly — the extra pass happens after the work is done — so the error is cosmetic in terms of your drawing.

It is not entirely cosmetic in terms of your session, though. The last statement in the routine switches command echo back on, and because the error aborts before reaching it, command echo is left switched off. If AutoCAD goes quiet after you run this, type CMDECHO and set it back to 1.

Your text style needs a fixed height. The text is placed by driving AutoCAD’s TEXT command with a fixed list of responses that does not include a height. If the current text style has its height set to zero, TEXT will ask for one, the responses will land in the wrong slots and the labels will come out wrong or not at all. Set a style with a defined height before running it.

Command reference

The file defines a single command, and it is short: DB. Not DISTBEAR, which is the filename. Type DB after loading.

How to load it

Distbear.zip holds DISTBEAR.LSP and a short help file. Load the LSP with APPLOAD, or add it to the Startup Suite. Because DB is such a short command name, check it does not collide with anything else you load — whichever routine loads last wins. See our AutoLISP guide for loading options.

Step-by-step usage

  1. Set AUNITS to the angle format you want the bearings in, and make the layer and a fixed-height text style current.
  2. Type DB. It prints its version banner, then “Select line(s) to attach distance & bearing labels to”.
  3. Select the lines. Any method works; non-line objects are filtered out.
  4. It reports “Verifying the selected entities….” and how many lines it found, then labels each one, echoing the distance and angle to the command line as it goes.
  5. Expect the error line described above at the end. Check your labels, then reset CMDECHO to 1.

Compatibility notes

Written between 1990 and 1994, so written-for rather than tested-on. It is plain AutoLISP: no dialog boxes, no Express Tools calls, just selection sets, entity data and the TEXT command. That means nothing in it requires the full product, and LT users on LT 2024 or later — the release that brought AutoLISP to LT — should be able to run it. See what runs on AutoCAD LT. The help file notes that the text takes on the properties of the current style, which is still true.

Download

Name: Distance and Bearing Angle.
Description: Routine creates a text entity that specifies the distance
(length) and bearing (angle) of a select line or pline
segment. Used in surveying and map making.
Type: AutoCAD AutoLISP Routine
Author: Anon
File Size: 2 Kb
Cost: Free
Worked on: AutoCAD
Download File: Distbear.zip

Related routines

  • COGO bearing and distance label — the same job with far more control over text placement and content.
  • ImportXYZ — bring survey coordinates into the drawing in the first place.
  • ZP — export block coordinates and levels back out to a text file.

References

  • AutoLISP: the complete guide
  • Free LISP routines library
  • AutoLISP on AutoCAD LT

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