• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
blog.draftsperson.net

blog.draftsperson.net

the art of technical drawing

blog.draftsperson.net

UXS LISP: Unload Xrefs, Save and Reload in One Command

September 19, 2020

Last updated July 28, 2026

Three lines of AutoLISP that solve one specific, maddening problem. UXS unloads every xref in the current drawing, saves the file, then reloads them all again. That sequence — unload, save, reload — is the workaround for a Revit link behaving badly, and doing it by hand through the External References palette a dozen times a day gets old fast.

The problem it was written for

An xref can be attached in one of two ways. An attachment travels with the drawing when that drawing is itself referenced somewhere else. An overlay does not — that is the entire point of overlays, and it is how you stop a linked drawing dragging its own references into the host file.

The behaviour that prompted this routine appeared with AutoCAD DWGs linked into Revit 2015: overlays inside the linked DWG intermittently started showing up in the Revit link, as though they had been attached rather than overlaid. That is not how overlays are supposed to work, and it produces a Revit view with geometry in it that nobody asked for.

There was no fix available at the DWG end, only a workaround: unload the xrefs, save the drawing in that state, then reload them and carry on working. Saved that way, the file behaves in the Revit link. This routine does those three steps on one command so the workaround costs a few seconds rather than a trip through the palette.

What it does in practice

It runs the command-line version of XREF three times over. First it unloads every reference in the drawing using the wildcard for all names. Then it issues a quiet save. Then it reloads every reference, again by wildcard. Your xrefs are back on screen when it finishes, and the copy of the drawing on disk is the unloaded one.

Two things follow from that, and both matter.

It saves without asking. The middle step is a straight save of the current drawing. There is no confirmation prompt and no chance to think about it. If you have unsaved changes you were not ready to commit, they are committed. That is deliberate — the whole workaround depends on the file being written to disk in the unloaded state — but it is worth knowing before you type the command out of curiosity.

It is all or nothing. The wildcard means every xref in the drawing is unloaded and reloaded, not just the overlays or a selection. In the situation it was written for that is exactly right. If you keep some references deliberately unloaded, they will come back loaded.

Command reference

One command: UXS. Unload, Xrefs, Save — and reload.

How to load it

Unzip UXS.zip and load UXS.LSP with APPLOAD. If you are fighting this problem daily, put it in the Startup Suite so the command is always there. There are no support files and nothing to configure. Our AutoLISP guide covers loading.

Step-by-step usage

  1. Finish whatever you were doing. The routine will save the drawing whether you are ready or not.
  2. Type UXS.
  3. The xrefs disappear, the drawing saves, the xrefs come back. No prompts.
  4. Reload the DWG link in Revit and check the offending geometry has gone.

If you want the safer version, edit the file and change the save step from the quiet save to the ordinary one, which will prompt if there is anything to decide. It is a one-word change on the middle line.

Is this still needed?

The routine was written in June 2015 against AutoCAD 2015 and Revit 2015, and the behaviour it works around was specific to that generation. If you are on current versions, check whether the problem still occurs before adopting the workaround — there is no sense saving in an unloaded state if nothing requires it.

The command is still useful for its own sake, though. Unload-save-reload is a reasonable thing to want on one keystroke any time a host application is misreading your references, and the same three lines will do it.

Compatibility notes

Plain AutoLISP driving the command-line XREF and a save. No dialog boxes, no Express Tools calls, nothing version-specific in the code itself, so it should run wherever AutoLISP does — including AutoCAD LT 2024 and later, the first LT releases with AutoLISP support. See what runs on AutoCAD LT. Because it saves the drawing, try it on a copy the first time so the behaviour holds no surprises.

Download

Name: UXS
Description: A problem started to happen in Revit 2015 with linked AutoCAD dwg files
with xrefs contained within as overlays. The overlays intermittently re-appear
and behave as an ‘attached’ xref not an ‘overlay’ xref. This is not normal behavior
as xref overylays should not be showing in a Revit link. A work around solution is
to unload the xref, save the file, then reload the xref and continue working.
I have created a simple LISP command to do all of this quickly.
Type: AutoCAD AutoLISP Routine
Author: YZ
File Size: 1 Kb
Cost: Free
Worked on: AutoCAD 2015, Revit 2015
Download File: UXS.zip

Related routines

  • LLP Suite — includes several xref listing and management commands.
  • UPDBLOCK — another drawing clean-up utility for work being sent on.
  • Best of LISP collection — general drafting utilities.

References

  • AutoLISP: the complete guide
  • Free LISP routines library
  • AutoLISP on AutoCAD LT

Filed Under: AutoLISP Routines

Primary Sidebar

Subscribe to our Youtube Channel

Post CAD drafting jobs on Freelancer.com. and get some free money to do this.

Categories

  • American Steel Industry (4)
  • AutoCAD Articles & Reference (30)
  • AutoCAD Bugs & Problems (19)
  • AutoCAD Tips (29)
  • AutoCAD Tutorials (54)
  • AutoLISP Routines (328)
  • AutoLISP Tutorials (15)
  • CAD Standards (7)
  • Civil 3D (7)
  • Civil Drafting (4)
  • Dimensions (2)
  • Drafting Funnies (71)
  • Drafting History (9)
  • Drafting Standards (84)
  • Electrical Drafting (2)
  • General IT reference (7)
  • Geometry (15)
  • GIS (2)
  • Hatch Patterns (12)
  • Office Life Hacks (3)
  • PT (1)
  • Revit Tutorials (54)
  • Steel Detailing (14)
  • Structural Drafting (26)
  • Technical Dictionary (61)
  • Useful Website Links (19)

Footer

Free downloads

  • Free AutoLISP routines
  • Free hatch patterns
  • SHX fonts & text styles
  • Numbering LISP collection
  • ISO 3098B font

Reference charts

  • AWS weld symbols chart
  • Steel detailing chart
  • Hole & slot sizes
  • Bolt edge distance
  • ANSI & ARCH paper sizes
  • How to fold an A1 drawing

Useful links

  • CAD blocks (DWG)
  • Revit families
  • structuraldrafter.com
  • cad-corner.com
  • About
  • Privacy policy

Provided for free with no warranty · Log in