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
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
;; 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
- 1Download and review the source code.
- 2Load the .lsp file with APPLOAD in a copy of a drawing.
- 3Keep the routine session-only until it has been tested for your CAD version and standards.
Command workflow
How to run the HOLETABLE command
- 1Run HOLETABLE.
- 2Select hole circles.
- 3Pick the MTEXT list insertion point.
Worked example
Example: Create a coordinate list for plate holes.
- Run HOLETABLE.
- Select the hole circles.
- Place the list.
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