Replace an XREF with another XREF. Post 5 in series “AutoCAD Cleanup”

If you are using XREFs for borders, you can use script to replace a current border with a different one. This example assumes that

  • the layer G-Xref exists (but if not, you can script making it
  • the border needs to be overlayed in the paperspace
  • old and new border have the same position in respect to 0,0,0

The following script replaces the XREF border CD_SHEET_E_VERT in paperspace. You may use it to replace XREF borders from a consultant with your company border.

The new border BR08-4851.DWG is overlaid on G-XREF layer and its full path is then converted to relative path (we will talk more about full and relative paths in future posts)

TILEMODE 0
 -XREF D CD_SHEET_E_VERT
 -LAYER S G-XREF
 blank line
 -XREF O P:\4000\4851\DRAWINGS\REF\ARCH\BR08-4851.DWG
 0,0,0 1 1 0
 -XREF P “BR08-4851″
 ..\..\REF\ARCH\BR08-4851.DWG
 QSAVE
 blank line