RenameBlock

Short description

🚀 RenameBlock is an AutoCAD AutoLISP utility for quickly renaming a selected block definition directly from a picked block reference. It improves DWG block management by letting CAD users select a block in the drawing, enter a new block name, and apply the standard AutoCAD block rename workflow without needing to know the original block definition name.

Command:

🧰 Load RenameBlock2.lsp with APPLOAD, startup suite, or another AutoCAD LISP loader.
▶️ Run RenameBlock to start the command.
📌 The command function is C:RenameBlock.
🎯 Target platform: AutoCAD, AutoCAD Civil 3D, and AutoCAD-based products that support Visual LISP and ActiveX COM.
⚠️ The tool uses AutoCAD _.RENAME with the _BLOCK option, so it renames the block definition used by the selected block reference.

Description:

📘 RenameBlock helps AutoCAD and Civil 3D users rename block definitions from the drawing area without manually opening the full AutoCAD Rename dialog or searching for the existing block name.

🔍 The user selects a block reference, and the program reads the correct block name from the selected INSERT object. For dynamic blocks, it checks the EffectiveName property when available, so the displayed base block definition name is used instead of only the anonymous reference name.

📝 After the block is selected, the selected block is highlighted and the current block name is opened in the AutoCAD lisped text editor as the default editable value. The user can keep the name or type a new valid block name.

🧠 The routine validates the new name before applying it. Empty names, spaces-only names, and names already used by another block definition are rejected. If the user confirms a different valid name, the LISP runs _.RENAME and renames the block definition in the active DWG.

🔴 Important: this is a block definition rename utility. Renaming the block definition affects all block references that use that definition in the current drawing. It does not create a copied block definition for only one selected reference.

Helper function: (if any)​

  • 🚀 Command entry pointC:RenameBlock starts the block rename workflow and manages selection, validation, rename execution, and cleanup.
  • 🔍 Block-only selection logic — the routine uses ssget "_I" with an INSERT filter for preselected blocks, then falls back to entsel when needed.
  • 🧩 Dynamic block name support — the code checks vlax-property-available-p for EffectiveName so dynamic block references can be resolved to their effective block definition name.
  • 🔒 Xref protection — the routine checks the block table record and avoids processing xref-style block definitions using the assoc 1 test.
  • 📝 Text-editor name input — the command uses lisped with the current block name as the editable default, making block rename input faster and less error-prone.
  • 🔴 Name validation — empty strings, spaces-only names, and duplicate block names are blocked before the AutoCAD rename command is executed.
  • 📌 Visual feedbackredraw highlights the selected block reference during the rename workflow and removes the highlight at the end.
  • 🔄 Undo-safe workflow — the command wraps the operation with vla-startundomark and vla-endundomark, making the rename action easier to reverse with AutoCAD Undo.
  • 🧹 Command echo handlingCMDECHO is temporarily disabled while _.RENAME runs, keeping the command line cleaner.
  • 🔐 Error cleanup — the local *error* handler restores highlighting state, ends the undo mark, and reports non-cancel errors.

Functionalities:

  • 🚀 Rename selected block — select a block reference in the DWG and rename its block definition directly.
  • 🔍 Use preselected block — if exactly one block is already selected, the command can use that block immediately.
  • 🧩 Dynamic block awareness — reads EffectiveName when available for dynamic block references.
  • 🔒 Xref exclusion — avoids renaming external reference definitions that should not be handled like normal blocks.
  • 📝 Editable default name — opens the current block name as the default value in lisped.
  • 🔴 Duplicate-name prevention — rejects new block names that already exist in the current drawing.
  • 📌 Selection highlight — highlights the chosen block during the command so the user can confirm the target visually.
  • 🔄 Undo mark support — groups the rename operation for cleaner AutoCAD undo behavior.
  • 🧹 Command-line cleanup — temporarily suppresses command echo during the rename operation.
  • 🏷️ DWG block management — useful for cleaning, standardizing, and organizing AutoCAD block libraries in production drawings.

Result:

✅ The final result is a cleaner AutoCAD or Civil 3D drawing where a selected block definition has been renamed quickly and consistently. The tool saves time during DWG cleanup, block library organization, CAD standardization, and block management tasks by removing the need to manually locate the block definition name before using AutoCAD Rename.

Images, animations etc.

Pixel

Share this page:

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Tags: 🏷️ Autocad Lisps, 🏷️ Blocks, 🏷️ Blocks_menu
0
Would love your thoughts, please comment.x
()
x