eplisp

AutoCAD Replace Block LISP: Swap Blocks and Keep Attributes

Replaces the selected blocks with another block, keeping position, rotation, scale, layer and attribute values.

Commands: BLKSWAP

Load the downloaded .lsp file with the APPLOAD command in AutoCAD or GstarCAD, then type the command name. How to load a LISP file

Download all tools in one file (138 KB)

This AutoCAD replace block LISP adds the BLKSWAP command, which replaces the blocks you select with another block already defined in the drawing. Use it to swap an outlet symbol for a new one, or an old fixture block for the current version.

Each old block's insertion point, rotation, X/Y/Z scale (including negative scale on mirrored blocks) and layer carry over to the new block. If the old block has attributes, their values are written into attributes with the same tag in the new block, so labels, circuit numbers and ratings are not lost.

AutoCAD's Express Tools include BLOCKREPLACE, which replaces every insertion of one block name throughout the drawing. BLKSWAP works only on the blocks you select, and a single selection can contain blocks with different names that all become the same new block.

How to use it

  1. Load blkswap.lsp with APPLOAD and type BLKSWAP.
  2. Select the blocks to replace and press Enter; only blocks are picked up.
  3. Type the new block name, or type P and pick a sample block in the drawing.
  4. The blocks are replaced and the command line reports how many.

Notes and tips

  • The new block must already be defined in the drawing; bring it in with INSERT or DesignCenter first if needed.
  • Attribute values transfer only to attributes with matching tags; values with no matching tag in the new block are dropped.
  • Per-object overrides such as color and linetype, and dynamic block parameters, are not carried over.
  • The last block name you used is offered as the default for the rest of the session.

Frequently asked questions

How do I replace one block with another in AutoCAD?

Run BLKSWAP, select the blocks you want to replace, then type the new block name or pick a sample block. Position, rotation, scale and layer are kept.

How is this different from BLOCKREPLACE?

BLOCKREPLACE from Express Tools replaces every insertion of a block name in the drawing. BLKSWAP replaces only the blocks you select and copies attribute values to the new block by matching tags.

Are attribute values kept?

Yes, when the new block has an attribute with the same tag the value is written into it. If the tag names differ, that value is not transferred.