XRefs2Layers

Short description

๐Ÿ”—๐Ÿ“‚ Move all AutoCAD XREF block references onto clean XREF layers using either one shared _XREF layer or individual 0-XREF_ layers.

Image 000 15

Command:

๐Ÿš€ Primary command: XRefs2LayersOptions
๐Ÿ”˜ Option 1: XRefsTo_Xref / X2_XREF โ€” moves all detected XREF inserts to one layer named _XREF.
๐Ÿ“‚ Option 2: XRefsToLayers / X2L โ€” moves each XREF insert to its own layer using the 0-XREF_ prefix.
๐ŸชŸ Dialog helper: radioX2LDCL creates a small DCL option dialog for choosing the workflow.

Description:

๐Ÿ”— XRefs2Layers is an AutoCAD AutoLISP utility for organizing external reference inserts by layer.

๐Ÿ“‚ The tool scans the current drawing for XREF block definitions, ignores names matching *TBLOCK*, finds matching INSERT references, and moves those references to controlled XREF layers.

๐Ÿงญ The user can run a dialog-based workflow with XRefs2LayersOptions or run direct commands for a specific mode. One mode places every XREF on a shared _XREF layer, while the other mode creates separate 0-XREF_ layers for clearer drawing management.

๐Ÿ›ก๏ธ The routine uses ActiveX layer handling, undo marks, locked-layer recovery logic, and a final alert report showing how many XREFs were moved to each target layer.

Helper function: (if any)โ€‹

๐ŸชŸ writeX2LDCL โ€” writes the temporary DCL dialog for the two XREF layer options.
๐Ÿ”˜ radioX2LDCL โ€” loads the DCL, remembers the last selected option, and returns the selected workflow.
๐Ÿงญ XRefs2LayersOptions โ€” main option selector that launches the selected XREF layer command.
๐Ÿ“‚ XRefsToLayers / X2L โ€” creates or uses 0-XREF_ layers and moves each XREF to its matching named layer.
๐Ÿ”— XRefsTo_Xref / X2_XREF โ€” creates or uses the shared _XREF layer and moves all XREF inserts there.
๐Ÿ›ก๏ธ Error handlers โ€” close undo marks safely and report unexpected errors without interrupting normal cancel behavior.

Functionalities:

๐Ÿ”— XREF detection โ€” scans AutoCAD Blocks collection for definitions where IsXRef is true.
๐Ÿงน TBLOCK exclusion โ€” skips XREF names matching *TBLOCK* to avoid processing title-block style references.
๐ŸชŸ DCL option dialog โ€” provides a simple radio-button interface for choosing the layer organization mode.
๐Ÿ“‚ Per-XREF layer mode โ€” moves XREF inserts to uppercase layers named with the 0-XREF_ prefix.
๐ŸŸฆ Shared layer mode โ€” moves all XREF inserts to one standard _XREF layer.
๐Ÿงฑ Layer auto-create โ€” creates missing destination layers automatically.
๐Ÿ” Locked-layer handling โ€” temporarily unlocks the current layer when required so the XREF can be moved.
โ†ฉ๏ธ Undo mark support โ€” wraps processing in an undo mark for safer drawing edits.
๐Ÿ“Š Move report โ€” displays a summary alert showing counts by target layer.
โš™๏ธ Session memory โ€” remembers the last selected radio option during the active AutoCAD session.
๐Ÿšซ Zero-XREF warning โ€” alerts the user when no XREFs are found in the drawing.

Result:

โœ… The result is a cleaner AutoCAD drawing where XREF references are organized on predictable layers.

๐Ÿ“‚ CAD teams can quickly isolate, freeze, lock, audit, or plot XREF content by using either one shared _XREF layer or separate 0-XREF_ layers.

๐Ÿ“Š The final alert gives immediate feedback about how many XREF references were moved to each layer.

Images, animations etc.

Image 000 15
Image 001 6
Image 002 9
Image 003 3
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="XRefs2Layers">
<src:RibbonToolTip.ExpandedContent>
<StackPanel>
<TextBlock Background="AntiqueWhite" TextAlignment="Left">
<Bold>Function Syntax: XRefs2LayersOptions / X2L / XRefsToLayers / X2_XREF / XRefsTo_Xref</Bold>
<LineBreak/>
<Bold>Version: 1.0 Date: 20.06.2026 6:39:04PM</Bold>
<LineBreak/>
<Hyperlink>AI+https://www.cadtutor.net/forum/topic/20566-xrefstolayerslsp-move-xrefs-to-corresponding-layers/</Hyperlink>
<LineBreak/>

<Bold><Run Foreground="DodgerBlue">Function Syntax: XRefs2Layers</Run></Bold><LineBreak/>
<Bold><Run Foreground="Orange">Version: 1.0</Run></Bold><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">๐Ÿ”— SEO Friendly Description</Run></Bold><LineBreak/>
<Run Foreground="White">๐Ÿ”— XRefs2Layers is an AutoCAD AutoLISP tool for organizing external references by moving XREF insert references onto clean, predictable XREF layers.</Run><LineBreak/>
<Run Foreground="LimeGreen">๐Ÿ“‚ It improves CAD layer management, XREF visibility control, drawing cleanup, Civil 3D production organization, and DWG audit workflows.</Run><LineBreak/>
<Run Foreground="White">๐ŸชŸ The command includes a DCL option dialog so the user can choose between a shared XREF layer workflow and a per-XREF layer workflow.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">๐Ÿš€ Main Commands</Run></Bold><LineBreak/>
<Run Foreground="White">๐ŸชŸ Run </Run><Bold><Run Foreground="Orange">XRefs2LayersOptions</Run></Bold><Run Foreground="White"> to open the option dialog.</Run><LineBreak/>
<Run Foreground="White">๐Ÿ“‚ Run </Run><Bold><Run Foreground="Orange">XRefsToLayers</Run></Bold><Run Foreground="White"> or </Run><Bold><Run Foreground="Orange">X2L</Run></Bold><Run Foreground="White"> to move each XREF to its own </Run><Bold><Run Foreground="LimeGreen">0-XREF_&lt;XREF name&gt;</Run></Bold><Run Foreground="White"> layer.</Run><LineBreak/>
<Run Foreground="White">๐ŸŸฆ Run </Run><Bold><Run Foreground="Orange">XRefsTo_Xref</Run></Bold><Run Foreground="White"> or </Run><Bold><Run Foreground="Orange">X2_XREF</Run></Bold><Run Foreground="White"> to move all detected XREF inserts to one shared </Run><Bold><Run Foreground="LimeGreen">_XREF</Run></Bold><Run Foreground="White"> layer.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="LimeGreen">๐Ÿงฉ Functionalities</Run></Bold><LineBreak/>
<Run Foreground="White">๐Ÿ” </Run><Bold><Run Foreground="LimeGreen">XREF scan</Run></Bold><Run Foreground="White"> - scans the AutoCAD Blocks collection and detects block definitions where </Run><Bold><Run Foreground="Orange">IsXRef</Run></Bold><Run Foreground="White"> is true.</Run><LineBreak/>
<Run Foreground="White">๐Ÿงน </Run><Bold><Run Foreground="LimeGreen">TBLOCK exclusion</Run></Bold><Run Foreground="White"> - ignores XREF names matching </Run><Bold><Run Foreground="Orange">*TBLOCK*</Run></Bold><Run Foreground="White"> to avoid processing title-block style references.</Run><LineBreak/>
<Run Foreground="White">๐ŸชŸ </Run><Bold><Run Foreground="LimeGreen">Dialog selection</Run></Bold><Run Foreground="White"> - creates a temporary DCL window with radio buttons for choosing the target layer method.</Run><LineBreak/>
<Run Foreground="White">๐Ÿ“‚ </Run><Bold><Run Foreground="LimeGreen">Per-XREF layer mode</Run></Bold><Run Foreground="White"> - creates organized layers using the </Run><Bold><Run Foreground="Orange">0-XREF_</Run></Bold><Run Foreground="White"> prefix and the XREF name.</Run><LineBreak/>
<Run Foreground="White">๐ŸŸฆ </Run><Bold><Run Foreground="LimeGreen">Shared layer mode</Run></Bold><Run Foreground="White"> - places every detected XREF insert on the common </Run><Bold><Run Foreground="Orange">_XREF</Run></Bold><Run Foreground="White"> layer.</Run><LineBreak/>
<Run Foreground="White">๐Ÿงฑ </Run><Bold><Run Foreground="LimeGreen">Automatic layer creation</Run></Bold><Run Foreground="White"> - creates missing destination layers before moving the XREF insert references.</Run><LineBreak/>
<Run Foreground="White">๐Ÿ” </Run><Bold><Run Foreground="LimeGreen">Locked-layer recovery</Run></Bold><Run Foreground="White"> - temporarily unlocks the current layer when a layer change fails because of a locked layer state.</Run><LineBreak/>
<Run Foreground="White">โ†ฉ๏ธ </Run><Bold><Run Foreground="LimeGreen">Undo mark support</Run></Bold><Run Foreground="White"> - wraps edits in an AutoCAD undo mark for safer production use.</Run><LineBreak/>
<Run Foreground="White">๐Ÿ“Š </Run><Bold><Run Foreground="LimeGreen">Result report</Run></Bold><Run Foreground="White"> - displays an alert summary with the number of XREF inserts moved to each layer.</Run><LineBreak/>
<Run Foreground="White">โš™๏ธ </Run><Bold><Run Foreground="LimeGreen">Session memory</Run></Bold><Run Foreground="White"> - remembers the last selected option while the AutoCAD session remains open.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DodgerBlue">โœ… Practical Result</Run></Bold><LineBreak/>
<Run Foreground="White">โœ… The drawing becomes easier to manage because all XREF inserts are placed on predictable layers for visibility control, plotting, locking, freezing, and CAD standard review.</Run><LineBreak/>
<Run Foreground="LimeGreen">๐Ÿ“Œ This is useful for AutoCAD users, Civil 3D teams, CAD managers, drafting technicians, and production environments with many external references.</Run><LineBreak/>
<LineBreak/>
<Bold><Run Foreground="DarkRed">โš ๏ธ Important Notes</Run></Bold><LineBreak/>
<Run Foreground="White">โš ๏ธ The routine changes the layer assignment of XREF INSERT references in the active drawing.</Run><LineBreak/>
<Run Foreground="White">โš ๏ธ It does not modify the external source DWG files referenced by the XREFs.</Run><LineBreak/>
<Run Foreground="White">โš ๏ธ The per-XREF workflow can lock created XREF layers when the lock prompt is confirmed.</Run><LineBreak/>
<Run Foreground="White">โš ๏ธ Review project CAD standards before running this tool on production drawings.</Run><LineBreak/>



</TextBlock>
            
<Grid>
<Image Source="Image_000.jpg" Stretch="Uniform"/>
</Grid>

<Grid>
<Image Source="Image_001.jpg" Stretch="Uniform"/>
</Grid>

<Grid>
<Image Source="Image_002.jpg" Stretch="Uniform"/>
</Grid>

<Grid>
<Image Source="Image_003.jpg" Stretch="Uniform"/>
</Grid>




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

Share this page:

Leave a Reply

Page Tag: ๐Ÿท๏ธ Xref_menu

  • XRefs2Layers

    โ€”

    by

    Short description Command: Description: Helper function: (if any)โ€‹ Functionalities: Result: Images, animations etc. XAML code: Expand Code โ†“ Select Code Copy 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="XRefs2Layers"> <src:RibbonToolTip.ExpandedContent> <StackPanel> <TextBlock Background="AntiqueWhite" TextAlignment="Left"> <Bold>Function Syntax: XRefs2LayersOptions / X2L / XRefsToLayers / X2_XREF / XRefsTo_Xref</Bold> <LineBreak/> <Bold>Version: 1.0 Date: 20.06.2026 6:39:04PM</Bold> <LineBreak/> <Hyperlink>AI+https://www.cadtutor.net/forum/topic/20566-xrefstolayerslsp-move-xrefs-to-corresponding-layers/</Hyperlink> <LineBreak/> <Bold><Run Foreground="DodgerBlue">Function…

  • XrefsDrawingOrder

    โ€”

    by

    Short description Command: Description: Helper function: (if any)โ€‹ Functionalities: Result: Images, animations etc. XAML code: Expand Code โ†“ Select Code Copy Code Expand Code โฌ‡ Select Code Copy Code Additional info: Based on / Source code: Share this page:

  • UnReloadDetachSelectedXrefs_00

    โ€”

    by

    Short description Sort / Purpose: Interactive Xref management tool for AutoCAD that saves, reloads, and bulk-edits Xref state via a dialog, while preserving the current UCS and view for bulk actions. โ€ข Type of tool: Dialog-driven Xref control command with filters, selection, zoom-to-xref, save/load list, and batch operations. โ€ข Scope: Works on all Xrefs in…

  • ResetXrefLayers

    โ€”

    by

    Short description Comming soon … Command: Comming soon … Description: Comming soon … Helper function: (if any)โ€‹ Comming soon … Functionalities: Comming soon … Result: Comming soon … Images, animations etc. Lisp code: Expand Code โฌ‡ Select Code Copy Code Comming soon … /* ======= Theme ======= */ .lsp-theme { –bg: #111; –border: #2a2a2a; –text:…

  • Xref_menu

    Lisp code: Expand Code โ†“ Select Code Copy Code ; — auto-generated by LispLoader — ; Menu: Xref_menu ; Generated: 2026-06-09 07:42:24 (setq base "C:\\Users\\mateid\\OneDrive – DB E.C.O. Group\\@C3D\\@Dan_Templates\\Acad\\Support_files\\Lisps\\Help_File\\") (load (strcat base "Xref_menu\\AttachMultipleImages\\AttachMultipleImages.lsp")) (load (strcat base "Xref_menu\\AttachMultipleImagesPdfs\\AttachMultipleImagesPdfs.lsp")) (load (strcat base "Xref_menu\\AttachXrefsInLayouts\\AttachXrefsInLayouts.lsp")) (load (strcat base "Xref_menu\\Block2Xref\\BlockToXref.lsp")) (load (strcat base "Xref_menu\\ChangeColorInArea\\ChangeColorInArea.lsp")) (load (strcat base "Xref_menu\\ChangeXrefFromLayer\\ChangeXrefFromLayer.lsp")) (load (strcat…