CADLisp Tools

Dimensions & Annotation

Coordinate Label X/Y AutoLISP routine

Create a WCS X/Y text label at a picked coordinate. Download the .LSP source below and run the XYLABEL command after loading it.

⌘ XYLABELv1.1.0BeginnerUpdated Sep 18, 2026

What it does

Coordinate Label X/Y with the XYLABEL AutoLISP command

Transforms one picked point from the current UCS to WCS and creates a deterministic coordinate label using the current text size, layer, and style.

AutoLISP command
XYLABEL
Difficulty
Beginner

Applicable disciplines

CAD workflows that use this routine

Requirements and compatibility

What it needs

AutoLISP

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 coordinate-label.lsp AutoLISP code

coordinate-label.lspAUTOLISP
;; CADLisp Tools - Coordinate Label X/Y (WCS)
(defun ct-xy:current-layer-writable-p (/ row flags color)
  (and (setq row (tblsearch "LAYER" (getvar "CLAYER")))
       (setq flags (cdr (assoc 70 row)) color (cdr (assoc 62 row)))
       (= 0 (logand flags 21))
       (>= color 0)))

(defun ct-xy:make-text (point value / height normal rotation ucs-x)
  (setq height (getvar "TEXTSIZE")
        normal (trans '(0.0 0.0 1.0) 1 0 T)
        ucs-x (trans '(1.0 0.0 0.0) 1 0 T)
        rotation (angle '(0.0 0.0 0.0) (trans ucs-x 0 normal T)))
  (entmakex
    (list '(0 . "TEXT") (cons 8 (getvar "CLAYER"))
          (cons 10 (trans point 0 normal)) (cons 40 height)
          (cons 1 value) (cons 7 (getvar "TEXTSTYLE"))
          (cons 50 rotation) (cons 210 normal))))

(defun c:XYLABEL (/ *error* label point undo-started wcs)
  (defun *error* (message)
    (if undo-started (command-s "_.UNDO" "_End"))
    (if (and message (not (wcmatch (strcase message) "*CANCEL*,*QUIT*,*EXIT*")))
      (prompt (strcat "\nXYLABEL error: " message)))
    (princ))
  (cond
    ((not (ct-xy:current-layer-writable-p))
      (prompt "\nThe current layer is off, frozen, locked, or xref-dependent; no label created."))
    ((setq point (getpoint "\nPick point to label in WCS: "))
      (setq wcs (trans point 1 0)
            label (strcat "X=" (rtos (car wcs) 2 3) "  Y=" (rtos (cadr wcs) 2 3)))
      (if (= 0 (logand 8 (getvar "UNDOCTL")))
        (progn (command "_.UNDO" "_Begin") (setq undo-started T)))
      (if (ct-xy:make-text wcs label)
        (prompt "\nWCS coordinate label created.")
        (prompt "\nThe label could not be created."))
      (if undo-started (progn (command "_.UNDO" "_End") (setq undo-started nil)))))
  (princ))

Setup

How to install the coordinate-label.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 XYLABEL command

  1. 1Run XYLABEL.
  2. 2Pick the point to report.
  3. 3Review the WCS coordinate text.

Worked example

Example: Label an equipment setting-out point.

  1. Run XYLABEL.
  2. Snap to the point.
  3. Review the coordinate precision.
Expected result

Text at the point displays WCS X and Y to three decimals.

Read before use

Notes and limitations

  • Uses WCS coordinates and raw drawing units.
  • Creates non-associative TEXT.
  • Does not create on an off, frozen, locked, or xref-dependent current layer.
  • Not manually CAD-tested.

Version history

Changelog

v1.1.0Sep 18, 2026Correct UCS/WCS transformation, text orientation, layer checks, and undo grouping.
v1.0.0Sep 18, 2026Initial point-label routine.

Keep automating

Related tools

Geometry & Polylines6 disciplines

Distance Between Points

Report the 2D and 3D distance between two picked points.

⌘ PTDISTBeginnerCAD support: not tested
Updated Sep 18, 2026VIEW TOOL →
Dimensions & Annotation3 disciplines

Hole Coordinate Label

Label the WCS center X/Y coordinates of selected circles.

⌘ HOLEXYBeginnerCAD support: not tested
Updated Sep 18, 2026VIEW TOOL →
Data Extraction3 disciplines

Hole Coordinate Table

Create a simple MTEXT list of WCS circle-center coordinates.

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