Function Syntax: Command Version: 1 Date: 10.11.2025 N/A Description This updated AutoLISP program provides a professional interface to manage XREF layers directly from a single dialog window in AutoCAD. It supports both bulk reassignment of all XREF inserts to a chosen existing layer and per-XREF layer standardization using a configurable prefix. Main Purpose The program scans the current drawing for all attached XREFs and enables the user to:Assign all XREF inserts to one selected existing layer using a filtered layer selector. • Create dedicated layers for each XREF using a naming prefix (e.g. "xref_[xref name]"). • Assign each XREF block reference to its own target layer based on the prefix. • View and manage all XREFs in a dynamic DCL (Dialog Control Language) interface, including a live “Current Layer” report. Program Actions Scans the current drawing and detects every external reference (XREF) loaded in the drawing. Generates a temporary DCL dialog showing:  • A Select Layer (Filtered) panel to find an existing layer by name.  • A list of XREF names detected in the drawing.  • A Current Layer column that reports where each XREF insert currently resides:   – the layer name if all inserts share one layer,   – if inserts are on multiple layers,   – if no inserts are found.  • A Target Layer column built from the current prefix and XREF name. Provides quick-access buttons:  • Select All and Select None to control which XREFs are affected by “Create Layers” and “Assign Inserts”.  • Assign Layer (in the filtered panel) to move all XREF inserts to the selected matching layer and set that layer current.  • Create Layers to generate target layers for the selected XREFs using the prefix (white color, AutoCAD color 7).  • Assign Inserts to move selected XREF inserts to their corresponding target layers.  • Create + Assign to perform the two steps above in one action.  • OK to close the dialog (no additional actions are executed).  • Close to exit the dialog. Layer Creation Behavior • Each created layer follows the format: [Prefix][XrefName] (default prefix is "xref_"). • The layer color is automatically set to white (color 7). • The script checks if the layer already exists, updates its color if needed, and avoids duplicates. Assignment LogicAssign Layer applies to all XREF inserts in the drawing, regardless of selection, and can be used to force all XREFs onto one existing layer (e.g., layer “0”).Assign Inserts applies only to the selected XREFs in the list and moves each XREF’s inserts to its own computed target layer. • The program scans XREF inserts using standard INSERT entity traversal and updates entity layers with VLA-COM automation. • If an insert resides on a locked layer, the program temporarily unlocks that layer, updates the entity, and restores the lock state, preventing silent failures. • After any action, the “Current Layer” column refreshes immediately to reflect the real drawing state. User Workflow Type XrefLayers in AutoCAD’s command line. Use the Select Layer (Filtered) panel if you want to force all XREFs onto one existing layer:  • Enter a filter text (optional).  • Choose the target layer from Matching Layers.  • Click Assign Layer. Use the Layer Prefix area if you want standardized per-XREF layers:  • Set the prefix (e.g. xref_).  • (Optional) Select specific XREFs, or leave all selected.  • Click Create Layers and then Assign Inserts, or click Create + Assign. Click OK or Close to exit the dialog. Highlighted AutoLISP Commands(vl-load-com) – loads the COM interface for layer and block manipulation.(vla-get-Blocks) / (vla-get-IsXRef) – detects XREF block definitions.(ssget "_X" ...) and (entget) – scans INSERT entities and reads block names and layers.(vla-Add) / (vla-Item) – creates or retrieves layers.(vla-put-Layer) – assigns entities to a new layer (with lock-safe fallback).(load_dialog) and (new_dialog) – loads and displays the generated DCL UI. Key Advantages • Provides a single, consistent UI for both “bulk” and “per-XREF” layer management. • Eliminates manual layer creation and assignment errors. • Adds transparency with a live Current Layer report per XREF. • Handles locked-layer conditions reliably (no silent failures). • Fully self-contained: no external DCL file is required, it generates one dynamically at runtime. Command to Run Type XrefLayers in AutoCAD’s command prompt.