Search and Replace Attribute Text from the Command Line (-ATTEDIT)


AutoCAD's FIND command always opens the Find and Replace dialog box — which stops a script dead. For the text stored in block attributes (your title-block fields, tags, revision boxes and the like), AutoCAD's -ATTEDIT command runs entirely at the command line — no dialog and no LISP — so a Hurricane batch script can find and replace that text across hundreds of drawings unattended.

Scope — please read: -ATTEDIT works on block attribute text only. AutoCAD has no command-line find-and-replace for ordinary TEXT/MTEXT — that needs the interactive FIND dialog or Hurricane's LISP-based Search and Replace Text Wizard (full AutoCAD). Because -ATTEDIT is built in and needs no LISP, it also works in AutoCAD LT.

How the command-line prompts work

The global form of -ATTEDIT (answering No to “edit one at a time”) asks a fixed series of questions. Three are filters that narrow which attributes are touched; the last two are the actual find → replace text:

  1. Edit attributes one at a time? — answer No for global editing.
  2. Edit only attributes visible on screen? — answer No to process the whole drawing with no on-screen picking (essential for an unattended batch).
  3. Block name specification* for every block, or a name such as TITLEBLOCK. Wildcards * and ? are allowed.
  4. Attribute tag specification* for every tag, or one tag (e.g. REV, DATE).
  5. Attribute value specification* for any value, or a value so the change applies only where it currently matches.
  6. String to change — the literal text to find (a substring of the value).
  7. New string — the literal replacement.
The “string to change” is literal. The wildcard characters above work only in the block / tag / value filter specs — not in the find text itself.

Example: a Hurricane user-script

This replaces PRELIMINARY with ISSUED FOR CONSTRUCTION in every block attribute, across each drawing in your Hurricane queue:

; replace PRELIMINARY with ISSUED FOR CONSTRUCTION in all attributes
-ATTEDIT
N
N
*
*
*
PRELIMINARY
ISSUED FOR CONSTRUCTION
_QSAVE

Line by line: -ATTEDIT starts the command; the first N = not one at a time; the second N = not only on-screen (so the whole drawing); the three * lines accept every block, tag and value; then the text to find and its replacement; and _QSAVE saves the drawing. To target just one field, replace a * — e.g. block TITLEBLOCK, tag REV.

Comments & testing: a line that begins with a semicolon is ignored by AutoCAD, so you can document a script with full-line ; comments — but do not add a comment after an answer on the same line, as the spaces before it are read as extra Enter presses and throw the prompts out of step. Always run a new replace on one drawing first to confirm the prompt order in your AutoCAD release before batching.
★ Hurricane ships ready-to-use examples. You don't have to write this from scratch — Hurricane includes a set of ready-to-edit -ATTEDIT find-and-replace example scripts. Open one, change the block/tag and the find/replace text, and run it across your whole queue. For LISP-based text replacement on full AutoCAD, see the Search and Replace Text Wizard.
📚 Discussed on the Hurricane Forum: find and replace MText · Search & Replace MText within a block · Problem with find and replace MTEXT

Related


PreviousBack to Hurricane for AutoCAD - FAQNext