CADLisp Tools

Data Extraction

Hole Coordinate Table AutoLISP routine

Create a simple MTEXT list of WCS circle-center coordinates. Download the .LSP source below and run the HOLETABLE command after loading it.

⌘ HOLETABLEv1.1.0IntermediateUpdated Sep 18, 2026

What it does

Hole Coordinate Table with the HOLETABLE AutoLISP command

Transforms selected circle centers to WCS in selection order and places a numbered X/Y coordinate list at a chosen insertion point.

AutoLISP command
HOLETABLE
Difficulty
Intermediate

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

hole-coordinate-table.lspAUTOLISP
;; CADLisp Tools - Hole Coordinate Table (WCS)
(defun ct-ht: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-ht:make-mtext (point value / normal ucs-x)
  (setq normal (trans '(0.0 0.0 1.0) 1 0 T)
        ucs-x (trans '(1.0 0.0 0.0) 1 0 T))
  (entmakex
    (list '(0 . "MTEXT") (cons 8 (getvar "CLAYER"))
          (cons 10 point) (cons 40 (getvar "TEXTSIZE"))
          (cons 1 value) (cons 7 (getvar "TEXTSTYLE"))
          '(71 . 1) (cons 11 ucs-x) (cons 210 normal))))

(defun c:HOLETABLE (/ *error* center content data ent i point 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 "\nHOLETABLE error: " message)))
    (princ))
  (cond
    ((not (ct-ht:current-layer-writable-p))
      (prompt "\nThe current layer is off, frozen, locked, or xref-dependent; no table created."))
    (T
      (prompt "\nSelect hole circles: ")
      (if (setq ss (ssget '((0 . "CIRCLE"))))
        (if (setq point (getpoint "\nTable insertion point: "))
          (progn
            (setq i 0 content "HOLE  X  Y")
            (repeat (sslength ss)
              (setq ent (ssname ss i) data (and ent (entget ent)))
              (if (and data (assoc 10 data))
                (progn
                  (setq center (trans (cdr (assoc 10 data)) ent 0)
                        content (strcat content "\\P" (itoa (1+ i)) "  "
                                        (rtos (car center) 2 3) "  "
                                        (rtos (cadr center) 2 3)))))
              (setq i (1+ i)))
            (if (= 0 (logand 8 (getvar "UNDOCTL")))
              (progn (command "_.UNDO" "_Begin") (setq undo-started T)))
            (if (ct-ht:make-mtext (trans point 1 0) content)
              (prompt "\nWCS coordinate table created.")
              (prompt "\nThe coordinate table could not be created."))
            (if undo-started (progn (command "_.UNDO" "_End") (setq undo-started nil))))
          (prompt "\nNo insertion point supplied."))
        (prompt "\nNo circles selected."))))
  (princ))

Setup

How to install the hole-coordinate-table.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 HOLETABLE command

  1. 1Run HOLETABLE.
  2. 2Select hole circles.
  3. 3Pick the MTEXT list insertion point.

Worked example

Example: Create a coordinate list for plate holes.

  1. Run HOLETABLE.
  2. Select the hole circles.
  3. Place the list.
Expected result

A numbered WCS X/Y list is created as MTEXT.

Read before use

Notes and limitations

  • Selection order controls row order.
  • Creates plain MTEXT rather than a native TABLE.
  • 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, MTEXT orientation, layer checks, and undo grouping.
v1.0.0Sep 18, 2026Initial selection-order MTEXT list.

Keep automating

Related tools

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 Extraction6 disciplines

Export Block Attributes to CSV

Export selected block names and attribute tag/value pairs to a CSV file.

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