There are actually a few minor issues that I found with this routine originally, so I made my own update to it version using this as a base, it really did provide a good starting point.
You can see my thread on this at:
http://www.theswamp.org/index.php?topic=56734.msg604613#msg604613I have also attached the latest version to this post.
Please note that this only works properly on the first run of the routine. Also, my purge routine is quite detailed, so it does slow things down slightly, but it makes sure to get rid of everything that can be purged and often takes a drawing down from 2+ MB to under 500 KB, making it run much faster as well, so a few extra seconds spent now will save 30+ minutes later.
In case you are wondering what some of the issues were, here are some of them:
- Would not work properly, unless drawing was completely purged prior to running the command. So, I added my own purge routine to it.
- Would not remove xrefs, etc. if the referenced file was missing, but the file was still loaded. (Yellow Triangles), my version corrected this.
- Had issues with nested references, I was able to add in some code from some of my other routines that I had written in the past that deal with nested xRefs to handle this better.
- Would return an error if there was a block with the same name as an xRef. In theory AutoCAD shouldn't allow this to happen, but there are circumstances where it does. I was able to add in a way to rename the block if this happens, which prevents the error.
As you will be able to see, my version is more of an evolution of what came before than a complete rewrite, so my hats off to Igal Averbuh and T.Willey, as I would never have been able to do this without their original code.
Please test and let me know what you think.
ETA: One key detail to note is that changes are not reflected in the XREF palette until you save and close the drawing and reopen it. The changes should be reflected in the classicxref dialog box right away, but sometimes they aren't. When in doubt, save the drawing, close it and reopen it.