All_Color2Layers

Short description

🎨 All_Color2Layers is an AutoCAD AutoLISP ByLayer cleanup utility for resetting entity color and/or linetype overrides to BYLAYER.
🧰 It adds a DCL interface with operation options, scope controls, layout filtering, layer selection, settings memory, and undo support.

Command:

🚀 Main dialog command: BYLAYERDLG – opens the ByLayer Tool DCL interface
🚀 Alias command: BYLAYER – runs the same DCL interface
🚀 Command-line mode: BYLAYERCMD – runs Color/Linetype/Both from the command line
🚀 Diagnostic command: BLDEBUG – writes a debug report for DCL/environment troubleshooting

Description:

🎨 All_Color2Layers is an SEO-friendly AutoCAD entity cleanup utility for resetting object color and linetype overrides to BYLAYER.
🧰 The BYLAYERDLG command writes a temporary DCL dialog with Color only, Linetype only, and Both operation modes.
🗂️ The dialog includes scope toggles for Model Space, Paper Spaces, and Block Definitions, plus a layout filter and multi-select list.
↩️ Apply creates an undo mark and the custom Undo button reopens the dialog after running AutoCAD UNDO 1.
🔍 The code unlocks locked layers temporarily, processes non-xref blocks/entities, restores layer locks, and stores dialog settings with getcfg/setcfg.

Helper function: (if any)​

🧩 BL:Get and BL:Set read and write persistent dialog settings through the AutoCAD configuration store.
🧩 BL:WriteDcl creates a fresh temporary DCL file to avoid stale or locked dialog files.
🧩 BL:Process applies the original ByLayer logic across selected scope areas and restores locked layers.
🧩 BL:Filter, BL:FillList, and BL:UpdSel manage the layer/layout list and selection count.
🧩 BL:OnApply wraps processing in a document undo mark and updates the status text.
🧩 BLDEBUG writes an environment and DCL diagnostic log for troubleshooting.

Functionalities:

✅ Reset entity Color to BYLAYER.
✅ Reset entity Linetype to BYLAYER.
✅ Reset both Color and Linetype in one operation.
✅ Choose processing scope: Model Space, Paper Spaces, and Block Definitions.
✅ Filter layouts/layers with wildcard-style filtering.
✅ Select all or select none in the DCL list.
✅ Temporarily unlock locked layers and restore their lock state after processing.
✅ Save operation mode, scope, filter, and dialog position between sessions.
✅ Provide an undo button for the last ByLayer operation step.

Result:

🎯 The result is a cleaner AutoCAD drawing where object-level color and linetype overrides are returned to layer-driven CAD standards.
🧱 This improves layer management, plotting consistency, CAD auditing, and Civil 3D production file cleanup.

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="All_Color2Layers">
 <src:RibbonToolTip.ExpandedContent>
 <StackPanel>
 <TextBlock Background="AntiqueWhite" TextAlignment="Left">
<Bold>Function Syntax: BYLAYERDLG / BYLAYER / BYLAYERCMD / BLDEBUG</Bold>
<LineBreak/>
<Bold>Version: 1.1 Date: 20.06.2026 6:38:52PM</Bold>
<LineBreak/>
<Hyperlink>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/change-all-to-color-bylayer-linetype-replacement/td-p/1523288</Hyperlink>

<TextBlock TextWrapping="Wrap" Foreground="Black">
  <Run FontWeight="Bold">Function:</Run> bylayer – Force entity color and/or linetype to Bylayer.
</TextBlock>

<TextBlock TextWrapping="Wrap" Foreground="Black">
  <Run FontWeight="Bold">Overview:</Run>
  <LineBreak/>
  This command allows the user to convert all entities in the drawing so their color and/or linetype properties are set to <Run Foreground="DarkOrange" FontWeight="Bold">Bylayer</Run>.<LineBreak/>		
Routine to change all drawing entities color or linetype, or both to the assigned color and/or linetype.
</TextBlock>

<TextBlock TextWrapping="Wrap" Foreground="Black">
  <Run FontWeight="Bold">User Prompt:</Run>
  <LineBreak/>
  Upon execution, the user selects from three options:
  <LineBreak/>
  • <Run Foreground="Blue" FontWeight="Bold">Color</Run> – Change only colors to Bylayer.
  <LineBreak/>
  • <Run Foreground="Green" FontWeight="Bold">Linetype</Run> – Change only linetypes to Bylayer.
  <LineBreak/>
  • <Run Foreground="Purple" FontWeight="Bold">Both</Run> – Change both properties to Bylayer.
</TextBlock>

<TextBlock TextWrapping="Wrap" Foreground="Black">
  <Run FontWeight="Bold">Key Operations:</Run>
  <LineBreak/>
  • Unlocks all layers temporarily to allow modification.
  <LineBreak/>
  • Iterates over all blocks and entities (excluding XRefs).
  <LineBreak/>
  • Applies Bylayer color and/or linetype based on user selection.
  <LineBreak/>
  • Handles block attribute definitions – ensures nested attribute colors are also changed.
  <LineBreak/>
  • Restores original layer lock states after processing.
</TextBlock>

<TextBlock TextWrapping="Wrap" Foreground="Black">
  <Run FontWeight="Bold">Additional Notes:</Run>
  <LineBreak/>
  • Attributes inside INSERT entities with attribute definitions (`66=1`) are also modified.
  <LineBreak/>
  • Uses `vlax-property-available-p` to safely access color and linetype properties.
  <LineBreak/>
  • Fully supports nested block-level entity edits.
</TextBlock>

<TextBlock TextWrapping="Wrap" Foreground="Black">
  <Run FontWeight="Bold">Ideal For:</Run>
  <LineBreak/>
  • Cleaning up drawings.
  <LineBreak/>
  • Enforcing CAD standards.
  <LineBreak/>
  • Preparing files for plotting or standardization.
</TextBlock>

<Bold><Run Foreground="DodgerBlue">Description</Run></Bold><LineBreak/><Run Foreground="White">🎨 All_Color2Layers is an AutoCAD AutoLISP ByLayer cleanup tool for restoring entity color and linetype behavior to layer-controlled standards.</Run><LineBreak/><Run Foreground="LimeGreen">🧰 It is useful for CAD standards enforcement, plotting consistency, xref-independent cleanup, and production drawings where object overrides must be removed.</Run><LineBreak/><LineBreak/>
<Bold><Run Foreground="DodgerBlue">Function Syntax</Run></Bold><LineBreak/><Run Foreground="White">Main dialog command: </Run><Bold><Run Foreground="Orange">BYLAYERDLG</Run></Bold><Run Foreground="White">opens the ByLayer Tool DCL interface</Run><LineBreak/><Run Foreground="White">Alias command: </Run><Bold><Run Foreground="Orange">BYLAYER</Run></Bold><Run Foreground="White">runs the same DCL interface</Run><LineBreak/><Run Foreground="White">Command-line mode: </Run><Bold><Run Foreground="Orange">BYLAYERCMD</Run></Bold><Run Foreground="White">runs Color/Linetype/Both from the command line</Run><LineBreak/><Run Foreground="White">Diagnostic command: </Run><Bold><Run Foreground="Orange">BLDEBUG</Run></Bold><Run Foreground="White">writes a debug report for DCL/environment troubleshooting</Run><LineBreak/><LineBreak/>
<Bold><Run Foreground="DodgerBlue">SEO Optimized Overview</Run></Bold><LineBreak/><Run Foreground="White">🎨 All_Color2Layers is an SEO-friendly AutoCAD entity cleanup utility for resetting object color and linetype overrides to BYLAYER.</Run><LineBreak/><Run Foreground="White">🧰 The BYLAYERDLG command writes a temporary DCL dialog with Color only, Linetype only, and Both operation modes.</Run><LineBreak/><Run Foreground="White">🗂️ The dialog includes scope toggles for Model Space, Paper Spaces, and Block Definitions, plus a layout filter and multi-select list.</Run><LineBreak/><Run Foreground="White">↩️ Apply creates an undo mark and the custom Undo button reopens the dialog after running AutoCAD UNDO 1.</Run><LineBreak/><Run Foreground="White">🔍 The code unlocks locked layers temporarily, processes non-xref blocks/entities, restores layer locks, and stores dialog settings with getcfg/setcfg.</Run><LineBreak/><LineBreak/>
<Bold><Run Foreground="LimeGreen">Primary Workflow</Run></Bold><LineBreak/><Run Foreground="White">1️⃣ Run </Run><Bold><Run Foreground="Orange">BYLAYERDLG</Run></Bold><Run Foreground="White"> or BYLAYER to open the ByLayer Tool dialog.</Run><LineBreak/><Run Foreground="White">2️⃣ Choose Color only, Linetype only, or Both.</Run><LineBreak/><Run Foreground="White">3️⃣ Set the scope toggles for Model Space, Paper Spaces, and Block Definitions.</Run><LineBreak/><Run Foreground="White">4️⃣ Filter and select the relevant list entries, then click Apply.</Run><LineBreak/><Run Foreground="White">5️⃣ Use Undo in the dialog when the last cleanup step must be rolled back.</Run><LineBreak/><LineBreak/>
<Bold><Run Foreground="LimeGreen">Functionalities</Run></Bold><LineBreak/><Run Foreground="White">✅ Reset entity Color to BYLAYER.</Run><LineBreak/><Run Foreground="White">✅ Reset entity Linetype to BYLAYER.</Run><LineBreak/><Run Foreground="White">✅ Reset both Color and Linetype in one operation.</Run><LineBreak/><Run Foreground="White">✅ Choose processing scope: Model Space, Paper Spaces, and Block Definitions.</Run><LineBreak/><Run Foreground="White">✅ Filter layouts/layers with wildcard-style filtering.</Run><LineBreak/><Run Foreground="White">✅ Select all or select none in the DCL list.</Run><LineBreak/><Run Foreground="White">✅ Temporarily unlock locked layers and restore their lock state after processing.</Run><LineBreak/><Run Foreground="White">✅ Save operation mode, scope, filter, and dialog position between sessions.</Run><LineBreak/><Run Foreground="White">✅ Provide an undo button for the last ByLayer operation step.</Run><LineBreak/><LineBreak/>
<Bold><Run Foreground="DodgerBlue">Important Commands and Functions</Run></Bold><LineBreak/><Run Foreground="White">🧩 </Run><Bold><Run Foreground="Orange">BYLAYERDLG</Run></Bold><Run Foreground="White"> - main DCL command for the ByLayer cleanup interface.</Run><LineBreak/><Run Foreground="White">🧩 </Run><Bold><Run Foreground="Orange">BYLAYER</Run></Bold><Run Foreground="White"> - alias that opens the same interface.</Run><LineBreak/><Run Foreground="White">🧩 </Run><Bold><Run Foreground="Orange">BYLAYERCMD</Run></Bold><Run Foreground="White"> - command-line mode for Color, Linetype, or Both.</Run><LineBreak/><Run Foreground="White">🧩 </Run><Bold><Run Foreground="Orange">BL:Process</Run></Bold><Run Foreground="White"> - core object traversal and property reset function.</Run><LineBreak/><Run Foreground="White">🧩 </Run><Bold><Run Foreground="Orange">acbylayer</Run></Bold><Run Foreground="White"> - ActiveX color constant used to reset entity color.</Run><LineBreak/><Run Foreground="White">🧩 </Run><Bold><Run Foreground="Orange">vla-put-lock</Run></Bold><Run Foreground="White"> - temporarily unlocks and restores locked layers during cleanup.</Run><LineBreak/><LineBreak/>
<Bold><Run Foreground="LimeGreen">Result</Run></Bold><LineBreak/><Run Foreground="White">🎯 The result is a cleaner AutoCAD drawing where object-level color and linetype overrides are returned to layer-driven CAD standards.</Run><LineBreak/><Run Foreground="White">🧱 This improves layer management, plotting consistency, CAD auditing, and Civil 3D production file cleanup.</Run><LineBreak/><LineBreak/>
<Bold><Run Foreground="DarkRed">Important Notes</Run></Bold><LineBreak/><Run Foreground="White">⚠️ The routine can process many entities across model space, layouts, and block definitions; test scope settings before running on large project drawings.</Run><LineBreak/><Run Foreground="White">⚠️ It intentionally changes entity properties, so use undo or a backup when cleaning production files.</Run><LineBreak/><Run Foreground="White">⚠️ The code skips xref block definitions and avoids xref-style block names when traversing blocks.</Run><LineBreak/><LineBreak/>
<Bold><Run Foreground="Yellow">Tags</Run></Bold><LineBreak/><Run Foreground="Yellow">🏷️ AutoCAD, 🏷️ AutoLISP, 🏷️ Civil 3D, 🏷️ BYLAYER, 🏷️ Color Cleanup, 🏷️ Linetype Cleanup, 🏷️ Layer Standards, 🏷️ DCL Dialog, 🏷️ CAD Cleanup, 🏷️ All_Color2Layers</Run><LineBreak/>

</TextBlock>
 
 <!-- Use MediaElement for GIF (static first frame) and Image as fallback -->

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

Share this page:

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x