Find and Replace Text
text_find_replaceFind and replace literal text across model space, layouts, block definitions, and attributes, with dry-run preview and revision-guarded apply.
Instructions
Replace text in TEXT, MTEXT and block attributes (ATTRIB and ATTDEF).
Both engines search the same places (searched_scope): model space, every
paper layout, every named block definition - so the next insert does not
reintroduce the old text - and the attributes of every block reference in
any of them; an xref's block holds another file's text and is not searched.
searched_types is on the response because "no matches" and "that type was
never searched" are different answers. DIMENSION text is out of
scope: its text field holds the <> override placeholder rather than the
measurement, so editing it would break the association. Anonymous blocks
(*D - a dimension's rendered measurement - *T, *U, *X) are
renderings regenerated from their owner and are not searched either. A multi-line
attribute is matched and rewritten as the whole value (Line1\PLine2),
the same value block_get_attributes reports and block_explode bursts.
dry_run=True adds preview: the document's content revision, the exact
fingerprint of every matched entity and the planned rows. Applied with that
revision (expected_revision) and/or its preconditions, the search runs
again first: an edited entity, a moved revision or a new match the preview
did not list refuses the call with kind stale_revision and nothing is
replaced. A guarded apply reports revision ({checked, after, interleaved}).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| find | Yes | Literal text to search for (not a regex). | |
| layer | No | Restrict to one layer. Empty searches every layer. | |
| dry_run | No | Report what would change, with a `preview` to apply it by; change nothing. | |
| replace | Yes | Replacement text. | |
| match_case | No | Case-sensitive search. | |
| preconditions | No | A dry run's `preview.preconditions` ({handle, fingerprint} per match): apply only if each is unchanged and nothing else now matches; otherwise refused stale_revision and nothing is replaced. | |
| expected_revision | No | Apply only at this content revision (a dry run's `preview.revision`); otherwise refused stale_revision and nothing is replaced. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||