XRefs2Layers

Short description

  • Goal: Manage how external references (XRefs) are reassigned to layers in the current drawing.
  • Modes: Either move all XRefs to a single _XREF layer or move each XRef to its own 0-XREF_<XRefName> layer.
  • User experience: Presents a DCL dialog with radio buttons and remembers the last selected option for the next run.
xrefs2layers 000

Command:

  • Primary launcher: XRefs2LayersOptions (shows the options dialog and runs the selected mode).
  • Mode A: XRefsTo_Xref (moves all XRef inserts to layer _XREF).
  • Mode B: XRefsToLayers (moves XRef inserts to 0-XREF_<XRefName> layers and optionally locks them).
  • Aliases: X2_XREF runs Mode A, and X2L runs Mode B.

Description:

  • Dialog driven selection: A temporary DCL file is generated and loaded to display two radio-button options.
  • State persistence: The last selected radio key is stored in *XRefs2Layers-last-option* (default rb01).
  • Execution: On OK, the chosen option is resolved to rb01 or rb02, saved, and the corresponding command is executed.
  • Cancel behavior: If the dialog is canceled, the routine exits with Command canceled.

Helper function: (if any)​

  • writeX2LDCL: Writes the DCL dialog definition to a temporary .dcl file.
  • radioX2LDCL: Loads the dialog, sets the last-used radio button, wires OK and Cancel actions, and returns a dialog result code.
  • Error handlers: Each processing command defines a local *error* handler to close the undo mark and print non-cancel errors.
  • COM initialization: Uses vl-load-com and ActiveDocument access to work with blocks, selection sets, and layers.

Functionalities:

  • XRef discovery: Scans block definitions for XRefs (excluding names matching *TBLOCK*) and builds a selection filter for XRef inserts.
  • Layer creation: Creates missing target layers (either _XREF or 0-XREF_<XRefName>).
  • Reassignment: Moves each XRef insert to the target layer; if the current layer is locked, it temporarily unlocks, moves, and re-locks.
  • Optional locking: In per-XRef mode, prompts to lock created XRef layers (default Yes).
  • Undo safety: Wraps changes in an undo mark for rollback consistency.
  • Reporting: Counts how many XRef inserts end up on each affected layer and displays a summary via alert.

Result:

  • If no XRefs exist: Displays an alert indicating there are zero XRefs in the drawing.
  • If XRefs are processed: Reassigns XRef inserts to the selected target layer scheme and shows an alert summary like N XRef(s) on layer: “LayerName”.
  • If canceled: No changes are applied and the command prints a cancel message to the command line.

Images, animations etc.

xrefs2layers 000
xrefs2layers 001
Pixel

Additional info:

Share this page:

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