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
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
;; 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
- 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 DUPTEXT command
- 1Run DUPTEXT.
- 2Select TEXT and MTEXT to inspect.
- 3Review the resulting duplicate selection.
Worked example
Example: Find accidentally stacked notes.
- Run DUPTEXT.
- Select the annotation area.
- Inspect highlighted duplicates.
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