CADLisp Tools

Dimensions & Annotation

Hole Coordinate Label AutoLISP routine

Label the WCS center X/Y coordinates of selected circles. Download the .LSP source below and run the HOLEXY command after loading it.

⌘ HOLEXYv1.1.0BeginnerUpdated Sep 18, 2026

What it does

Hole Coordinate Label with the HOLEXY AutoLISP command

Transforms selected circle centers from entity coordinates to WCS and creates one coordinate text label at each center for hole-layout and fabrication drawings.

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

hole-coordinate-label.lspAUTOLISP
;; CADLisp Tools - Hole Coordinate Label (WCS)
(defun ct-hx: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-hx: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:HOLEXY (/ *error* center created data ent i label skipped ss undo-started)
  (defun *error* (message)
    (if undo-started (command-s "_.UNDO" "_End"))
    (if (and message (not (wcmatch (strcase message) "*CANCEL*,*QUIT*,*EXIT*")))
      (prompt (strcat "\nHOLEXY error: " message)))
    (princ))
  (cond
    ((not (ct-hx:current-layer-writable-p))
      (prompt "\nThe current layer is off, frozen, locked, or xref-dependent; no labels created."))
    (T
      (prompt "\nSelect hole circles: ")
      (if (setq ss (ssget '((0 . "CIRCLE"))))
        (progn
          (setq created 0 skipped 0)
          (if (= 0 (logand 8 (getvar "UNDOCTL")))
            (progn (command "_.UNDO" "_Begin") (setq undo-started T)))
          (repeat (setq i (sslength ss))
            (setq ent (ssname ss (setq i (1- i))) data (and ent (entget ent)))
            (if (and data (assoc 10 data))
              (progn
                (setq center (trans (cdr (assoc 10 data)) ent 0)
                      label (strcat "X=" (rtos (car center) 2 3)
                                    " Y=" (rtos (cadr center) 2 3)))
                (if (ct-hx:make-text center label)
                  (setq created (1+ created))
                  (setq skipped (1+ skipped))))
              (setq skipped (1+ skipped))))
          (if undo-started (progn (command "_.UNDO" "_End") (setq undo-started nil)))
          (prompt (strcat "\nCreated " (itoa created) " WCS label(s); skipped " (itoa skipped) ".")))
        (prompt "\nNo circles selected."))))
  (princ))

Setup

How to install the hole-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 HOLEXY command

  1. 1Run HOLEXY.
  2. 2Select circles representing holes.
  3. 3Press Enter to create WCS center labels.

Worked example

Example: Label four plate-hole centers.

  1. Run HOLEXY.
  2. Select four circles.
Expected result

Each center receives a WCS X/Y text label.

Read before use

Notes and limitations

  • Treats every selected circle as a hole.
  • Creates non-associative TEXT at the center.
  • Uses raw drawing units and does not create on an unusable current layer.
  • Not manually CAD-tested.

Version history

Changelog

v1.1.0Sep 18, 2026Correct entity OCS/WCS conversion, text orientation, layer checks, and undo grouping.
v1.0.0Sep 18, 2026Initial circle-center label routine.

Keep automating

Related tools

Data Extraction4 disciplines

BOM from Block Attributes

Count selected blocks by one chosen attribute value.

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

Coordinate Label X/Y

Create a WCS X/Y text label at a picked coordinate.

⌘ XYLABELBeginnerCAD 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 →