CopyRenameBlockChangeLayer

Short description

🚀 Copy, rename, and relayer a selected AutoCAD block reference by creating a new independent block definition, preserving dynamic block behavior, and optionally updating all entities inside the copied block to ByLayer display properties.

Command:

CopyBlockChangeLayer | RB

Description:

🧩 CopyRenameBlockChangeLayer is an AutoCAD AutoLISP block utility based on the copy and rename block-reference workflow, extended with a DCL dialog for selecting a new block name and target layer.
🔄 The command can create a renamed copy of a selected block reference or rename the selected reference to a duplicated block definition, avoiding a global rename of every original block reference.
🧠 ObjectDBX cloning is used to duplicate the block definition safely, rename it, then copy it back into the active drawing under the new block name.
📌 Dynamic block properties are preserved by reading the dynamic property values before the rename and restoring them after the new block definition is assigned.
🎨 After the new block is created, the selected/new block reference can be placed on the chosen layer and the internal block entities can be forced to the same layer with color, linetype, and lineweight set to ByLayer.

Helper function: (if any)​

• LM:RenameBlockReference — main copy/rename engine for the selected INSERT entity.
• LM:GetNewBlockNameAndLayer — writes and opens the temporary DCL dialog used to capture the new block name and layer choice.
• update-layer-list — filters the layer popup list using wildcard matching while the user types.
• FixBlockEntitiesLayer_Internal — updates block-definition entities to the chosen layer and normalizes Color, Linetype, and Lineweight to ByLayer.

Functionalities:

• 🧱 Selects one AutoCAD block reference and validates that the picked object is an INSERT.
• 🔒 Rejects blocks located on locked layers to prevent unsafe modifications.
• 📝 Suggests a unique default block name using the original effective block name plus an incremental suffix.
• 📋 Opens a DCL dialog with New Block Name, Filter Layers, and Choose Layer controls.
• 🔍 Filters available non-xref layers with wildcard logic while the user types.
• 📦 Duplicates the original block definition through ObjectDBX before assigning the new name.
• 🧬 Supports dynamic blocks by preserving dynamic property values during the block-reference rename.
• 🧭 Handles anonymous block names and xref-reload behavior where applicable.
• 🎯 Selects the copied reference after the operation when copy mode is active.
• 🎨 Applies the target layer to the block reference and internal block entities.
• 🟨 Sets internal entity color to ByLayer, linetype to ByLayer, and lineweight to ByLayer for clean layer-driven display.

Result:

✅ The result is an independent renamed block copy or renamed block reference with controlled layer assignment, cleaner ByLayer graphics, and preserved dynamic-block behavior.

Images, animations etc.

Pixel

XAML code:

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:Autodesk.Windows;assembly=AdWindows">
    
<src:RibbonToolTip x:Key="Test">
<src:RibbonToolTip.ExpandedContent>
<StackPanel>
<TextBlock Background="AntiqueWhite" TextAlignment="Left">
<Bold>Function Syntax: Command</Bold>
<LineBreak/>
<Bold>Version: 1.0 Date: </Bold>
<LineBreak/>
<LineBreak/>
<Hyperlink>N/A</Hyperlink>
<LineBreak/>



<TextBlock TextWrapping="Wrap" Foreground="Black">
<Bold>Description</Bold><LineBreak/>
🚀 Copy, rename, and relayer a selected AutoCAD block reference by creating a new independent block definition, preserving dynamic block behavior, and optionally updating all entities inside the copied block to ByLayer display properties.<LineBreak/>
<LineBreak/>
<Bold>Function Syntax</Bold><LineBreak/>
• <Bold><Run Foreground="DarkRed">CopyBlockChangeLayer</Run></Bold><LineBreak/>
• <Bold><Run Foreground="DarkRed">RB</Run></Bold><LineBreak/>
<LineBreak/>
<Bold>SEO Friendly Description</Bold><LineBreak/>
🧩 CopyRenameBlockChangeLayer is an AutoCAD AutoLISP block utility based on the copy and rename block-reference workflow, extended with a DCL dialog for selecting a new block name and target layer.<LineBreak/>
🔄 The command can create a renamed copy of a selected block reference or rename the selected reference to a duplicated block definition, avoiding a global rename of every original block reference.<LineBreak/>
🧠 ObjectDBX cloning is used to duplicate the block definition safely, rename it, then copy it back into the active drawing under the new block name.<LineBreak/>
📌 Dynamic block properties are preserved by reading the dynamic property values before the rename and restoring them after the new block definition is assigned.<LineBreak/>
🎨 After the new block is created, the selected/new block reference can be placed on the chosen layer and the internal block entities can be forced to the same layer with color, linetype, and lineweight set to ByLayer.<LineBreak/>
<LineBreak/>
<Bold>Functionalities</Bold><LineBreak/>
• 🧱 Selects one AutoCAD block reference and validates that the picked object is an INSERT.<LineBreak/>
• 🔒 Rejects blocks located on locked layers to prevent unsafe modifications.<LineBreak/>
• 📝 Suggests a unique default block name using the original effective block name plus an incremental suffix.<LineBreak/>
• 📋 Opens a DCL dialog with New Block Name, Filter Layers, and Choose Layer controls.<LineBreak/>
• 🔍 Filters available non-xref layers with wildcard logic while the user types.<LineBreak/>
• 📦 Duplicates the original block definition through ObjectDBX before assigning the new name.<LineBreak/>
• 🧬 Supports dynamic blocks by preserving dynamic property values during the block-reference rename.<LineBreak/>
• 🧭 Handles anonymous block names and xref-reload behavior where applicable.<LineBreak/>
• 🎯 Selects the copied reference after the operation when copy mode is active.<LineBreak/>
• 🎨 Applies the target layer to the block reference and internal block entities.<LineBreak/>
• 🟨 Sets internal entity color to ByLayer, linetype to ByLayer, and lineweight to ByLayer for clean layer-driven display.<LineBreak/>
<LineBreak/>
<Bold>Helper Functions and Internal Logic</Bold><LineBreak/>
• <Bold><Run Foreground="DarkRed">LM:RenameBlockReference</Run></Bold>
 — main copy/rename engine for the selected INSERT entity.
<LineBreak/>
• <Bold><Run Foreground="DarkRed">LM:GetNewBlockNameAndLayer</Run></Bold>
 — writes and opens the temporary DCL dialog used to capture the new block name and layer choice.
<LineBreak/>
• <Bold><Run Foreground="DarkRed">update-layer-list</Run></Bold>
 — filters the layer popup list using wildcard matching while the user types.
<LineBreak/>
• <Bold><Run Foreground="DarkRed">FixBlockEntitiesLayer_Internal</Run></Bold>
 — updates block-definition entities to the chosen layer and normalizes Color, Linetype, and Lineweight to ByLayer.
<LineBreak/>
<LineBreak/>
<Bold>Result</Bold><LineBreak/>
<Run Foreground="DarkGreen">✅ The result is an independent renamed block copy or renamed block reference with controlled layer assignment, cleaner ByLayer graphics, and preserved dynamic-block behavior.</Run><LineBreak/>
<LineBreak/>
<Bold>Important Notes</Bold><LineBreak/>
• <Run Foreground="DarkOrange">⚠️ This tool modifies or creates block definitions in the active drawing. Use a saved drawing or backup when editing production block libraries.</Run><LineBreak/>
• <Run Foreground="DarkOrange">⚠️ The CopyBlockChangeLayer command uses copy mode, while RB uses rename mode without creating an extra copied reference.</Run><LineBreak/>
• <Run Foreground="DarkOrange">⚠️ The uploaded code header mentions historical CB/RB command names, but the implemented copy command in this file is CopyBlockChangeLayer.</Run><LineBreak/>
<LineBreak/>
<Bold>Tags</Bold><LineBreak/>
<Run Foreground="Goldenrod">🏷️ AutoCAD, 🏷️ AutoLISP, 🏷️ Civil 3D, 🏷️ Block Tools, 🏷️ Block Rename, 🏷️ Copy Block, 🏷️ Dynamic Blocks, 🏷️ ObjectDBX, 🏷️ DCL Dialog, 🏷️ Layer Management, 🏷️ ByLayer, 🏷️ CAD Productivity</Run><LineBreak/>
</TextBlock>



</TextBlock>
            
<Grid>
<Image Source="PNG" Stretch="Uniform"/>
</Grid>

<Grid>
<MediaElement
 Source="GIF"
 Stretch="Uniform"
 Visibility="Visible"/>
 </Grid>

</StackPanel>
</src:RibbonToolTip.ExpandedContent>
</src:RibbonToolTip>
</ResourceDictionary>



Additional info:

Share this page:

Tags: 🏷️ AutoCAD, 🏷️ AutoLISP, 🏷️ Block Rename, 🏷️ Block Tools, 🏷️ ByLayer, 🏷️ CAD Productivity, 🏷️ Civil 3D, 🏷️ Copy Block, 🏷️ DCL Dialog, 🏷️ Dynamic Blocks, 🏷️ Layer Management, 🏷️ ObjectDBX