Short description
Xref → Own Layer Manager
This AutoLISP routine scans the current drawing for attached xrefs, shows them in a dialog with a checkbox and a per xref layer popup, and lets the user create or assign layers for those xrefs in one place.
The dialog is generated dynamically so it always shows the exact xrefs that exist in the drawing at that moment.

Command:
Command Name: CreatesXrefsLayersAssign
Type CreatesXrefsLayersAssign in the AutoCAD command line to open the “Xref layers” dialog.
If no xrefs are found the program prints “No xrefs found.” and exits cleanly.
Description:
The dialog shows one row per found xref: a checkbox to include or skip that xref, the xref name, and a layer popup listing all layers in the drawing.
There are buttons to select all or select none, to create suggested layers for the checked xrefs, and to assign the chosen layers to all inserts of the checked xrefs in model space and paper space.
The routine also tries to detect the current insert layer of each xref and preselects it in the popup if it exists.
A status text at the bottom reports how many xrefs were found and how many layers are available for assignment.
Helper function: (if any)
Helper Functions:
• XRL-GetXrefs gets all xref block names from the drawing.
• XRL-GetLayers collects all layer names, sorts them, and caps the count so the DCL does not overload.
• XRL-GetFirstInsertLayer tries to find on which layer a given xref is inserted, in model space and then in paper space.
• XRL-EnsureLayer creates a layer if it does not exist and sets its color to 7 (white).
• XRL-MoveInsertsToLayer actually reassigns all inserts of an xref to the chosen layer.
• XRL-WriteDCL builds the dialog definition text on the fly with one row per xref.
These helpers make the dialog flexible and let it match whatever xrefs are present in the current file.
Functionalities:
Functionalities:
• Automatic xref detection: every external reference in the drawing is listed in the dialog.
• Per xref enable checkbox: only checked xrefs will be processed by create or assign actions.
• Per xref layer popup: each xref can be assigned to any existing layer through a dropdown.
• Create layers button: makes layers named _xref_xrefName for all checked xrefs, ensures they exist, refreshes the popups, and selects the new layer for those rows.
• Assign layers button: moves all inserts of the checked xrefs to the currently selected layer, in both model space and paper space.
• Select all and Select none: quick buttons to toggle all checkboxes in one click.
• Dynamic layer list: if new layers are created the dialog reloads the layer list so the new layers can be picked immediately.
• OK button: performs the assign action then closes the dialog.
• Close button: exits without changes.
Result:
Result / Outcome:
All selected xrefs are moved to the layers chosen in the dialog, so each external reference can live on its own dedicated layer (for example _xref_xrefname) for better control of visibility, plotting, and color.
This makes it very fast to standardize xref layers across drawings without manually searching for each xref insert.
Images, animations etc.




Additional info:
Learn more:
Open Website
Share this page:
Subscribe
Login
0 Comments
Oldest
Categories: AutoCAD_Lips
Tags: Blocks
Categories: AutoCAD_Lips
Tags: Blocks
