CADLisp Tools

Standards & QA

Detect Duplicate Text AutoLISP routine

Select duplicate TEXT or MTEXT at matching insertion points. Download the .LSP source below and run the DUPTEXT command after loading it.

⌘ DUPTEXTv1.0.0IntermediateUpdated Sep 18, 2026

What it does

Detect Duplicate Text with the DUPTEXT AutoLISP command

Compares selected text by exact stored value and rounded insertion coordinates, then highlights later duplicate occurrences for review.

AutoLISP command
DUPTEXT
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 detect-duplicate-text.lsp AutoLISP code

detect-duplicate-text.lspAUTOLISP
;; CADLisp Tools - Detect Duplicate Text
(defun ct-dt:text-value (data / pair value)
  (setq value "")
  (foreach pair data
    (if (member (car pair) '(1 3)) (setq value (strcat value (cdr pair)))))
  value)

(defun c:DUPTEXT (/ data ent i key out point seen ss text)
  (setq out (ssadd) seen nil)
  (prompt "\nSelect TEXT or MTEXT to inspect: ")
  (if (setq ss (ssget '((0 . "TEXT,MTEXT"))))
    (progn
      (setq i 0)
      (repeat (sslength ss)
        (setq ent (ssname ss i) data (and ent (entget ent)))
        (if (and data (assoc 10 data))
          (progn
            (setq text (ct-dt:text-value data)
                  point (trans (cdr (assoc 10 data)) ent 0)
                  key (strcat text "|" (rtos (car point) 2 8) "|"
                              (rtos (cadr point) 2 8) "|"
                              (rtos (if (caddr point) (caddr point) 0.0) 2 8)))
            (if (member key seen)
              (ssadd ent out)
              (setq seen (cons key seen)))))
        (setq i (1+ i)))
      (sssetfirst nil out)
      (prompt (strcat "\nDuplicate objects selected: " (itoa (sslength out)))))
    (prompt "\nNo text selected."))
  (princ))

Setup

How to install the detect-duplicate-text.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 DUPTEXT command

  1. 1Run DUPTEXT.
  2. 2Select TEXT and MTEXT to inspect.
  3. 3Review the resulting duplicate selection.

Worked example

Example: Find accidentally stacked notes.

  1. Run DUPTEXT.
  2. Select the annotation area.
  3. Inspect highlighted duplicates.
Expected result

Later text objects with the same content and insertion point are selected.

Read before use

Notes and limitations

  • Uses rounded insertion points and exact stored strings.
  • Does not delete duplicates.
  • Not manually CAD-tested.

Version history

Changelog

v1.0.0Sep 18, 2026Initial non-destructive duplicate detector.

Keep automating

Related tools

Standards & QA6 disciplines

Drawing Layer Checker

Report objects on Layer 0 or Defpoints and list locked, frozen, or off layers.

⌘ LAYERCHECKIntermediateCAD support: not tested
Updated Sep 18, 2026VIEW TOOL →
Drawing Cleanup6 disciplines

Purge/Audit Helper

Run CAD audit and one all-item purge pass only after explicit confirmation.

⌘ CLEANHELPIntermediateCAD support: not tested
Updated Sep 18, 2026VIEW TOOL →
Text & Numbering6 disciplines

Find & Replace Selected Text

Replace matching text inside a deliberate selection of TEXT and MTEXT objects.

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