Author: Matt Miyamoto AutoCAD
  1. Customer challenge: Large drawing file sizes
  2. Quick fix
  3. Avoiding future problems
  4. Automating -PURGE options with Autodesk script

Customer challenge: Large Drawing File Sizes

While at a recent custom training class here at Ideate, I was discussing the value of using the AutoCAD built-in drawing clean up tools with a customer. They had run into some drawing performance issues and although the file sizes were not extreme, there were some noticeable differences in the behavior of the drawing compared to what was expected.

Quick Fix

In this case, the blog post about standard drawing housekeeping tools that my fellow Application Specialist, Daniel Armstrong had written about provided great starting point.

After running through the housekeeping recommendations mention in Daniel’s post on the main file, we reduced the file size by over 50% and saw a significant improvement in performance, even with standard tools and commands.

Avoiding Future Problems

While discussing how they could incorporate this into their workflow, we looked at the additional options built into the -PURGE command. Along with items found in the standard PURGE command, -PURGE gives you access to purging RegApps, Orphaned Data, Zero-Length Geometry, and Empty Text objects. These can be difficult to identify in a drawing without the -PURGE command, since they are background data or objects that may not be visible or selectable on screen.


Items not in Standard -PURGE


There is an option for “ALL” under the -PURGE command, however that stops at the standard PURGE items and does not include the last four objects highlighted above.  Starting in 2015, the Orphaned Data option was added to the standard PURGE command, but it must be selected in the Purge dialog box in order for it to apply.


Screenshot of Text window after -PURGE:ALL


Here’s a screenshot of the Text Window after -PURGE: ALL. As you can see, it stops at Section View Styles and does not include RegApps, Orphaned Data, Empty Text, and Zero-Length Geometry. To remove these, you’ll need to manually repeat -PURGE four times and select the options one by one. 

Automating -PURGE Options With Autodesk Script

To help our customer make this smoother, we discussed the use of a simple Script (.SCR) file they could drag and drop into the drawing as needed. Since they were working with multiple groups across multiple locations, something like a script would be a faster and easier alternative than coordinating with their IT department to install additional tools and utilities or creating a command macro and distributing that to each user.

It only took a few minutes and a couple of tests to come up with a short script that would complete the process automatically.


Automate -PURGE script


It was created in Notepad as a .txt file, then the extension was changed to .scr to run it as an AutoCAD script.  The -PURGE command is repeated four times, running through the options for each of the missing items from the standard PURGE command. It includes extra lines for the options (<*> for names) and (<N> to verify each item) in the RegApp purge, but other than that, it’s exactly what you would type in (including <ENTER> key strokes) to run it manually.


Check text window to see what was found in the -PURGE process


After running the script, a quick check of the AutoCAD Text Window (F2) provides a recap of what was found in the process.

This turned out to be a quick solution that doesn’t involve installing additional tools or utilities and can be passed on to anyone running AutoCAD.  Since it’s a script (.SCR) file, using it is a simple drag and drop into the drawing area of the file you want to clean up. 

NOTE: Due to file format restrictions, the sample file is provided in .TXT format. To use the script in AutoCAD, copy the file and change the extension to .SCR (instead of .TXT). After the extension is changed, it is ready for use in AutoCAD (versions 2015-2018) by dragging and dropping it into the drawing area of an open file.

For more tips and tricks, visit our blog. For more information on the software solutions, training and consulting Ideate provides, please visit the Ideate, Inc. homepage.

      Matt Miyamoto
Matt Miyamoto
ENI Manager & Senior Application Specialist

Matt is an ENI Manager and Senior Application Specialist in Ideate, Inc.’s Seattle office. He has a B.S. in Mechanical Engineering and is a licensed Civil Engineer. Prior to joining Ideate, Matt worked as a civil engineer, using Civil 3D on a variety of projects including site development, roadway improvements and infrastructure design. With over 10 years of experience in the civil engineering industry, Matt now provides training, consulting, technical support, and implementation strategies for organizations transitioning to Civil 3D. Matt is an Autodesk Certified Instructor (ACI), as well as an Autodesk Certified BIM Specialist: Roads and Highway Solutions. Additionally, Matt is an Autodesk Certified Professional for AutoCAD, and AutoCAD Civil 3D. Find Matt on Twitter.