Keeping Your Drawings Clean

In this Click Savers I want to show how to build a tool that by using CTRL + a keystroke that will clean an AutoCAD drawing in seconds. The process that we will be going through will show you how a script of commands can be put together into one command and we will also look at how to add it to the CUI as a keyboard shortcut.

Below is the script that we will be putting into the CUI and creating a keystroke to execute it. At first glance this might look like a big mess but if you look at it closer it is starting certain commands at the command line using certain options of those commands. The dash (-) in front of the command is telling AutoCAD to not use the dialog box version of the command.

^C^C-PURGE;A;*;N;-PURGE;R;*;N;-PURGE;Z;AUDIT;Y;-SCALELIST;R;Y;;-PURGE;A;*;N;-OVERKILL;ALL;;;FILTERS;

You can see we are using the Purge command multiple times, once to purge all junk, another time to clean out the Regapps junk, the next one is the Zero-Length and empty Text objects junk. We are then running the Audit command to make sure that nothing in the drawing file has errors in it. Another nasty thing that can happen is the Annotation Scale Factors coming in from xrefs and blocks, we are deleting all of those but will not delete any that are in use. Doing one more purge to just make sure and then running the Overkill command to delete any overlapping objects that might be in the drawing. The last thing is running the Filters command to check to see if there too many of those in your drawing. This is the only one that you will need to pick on the Delete button to finish the routine.

To start, type in CUI at the command line and right-click in the Command List to create a new command and name it Clean Drawing.

In the Macro field, pick on the browse button and place the text string below into the dialog box:

^C^C-PURGE;A;*;N;-PURGE;R;*;N;-PURGE;Z;AUDIT;Y;-SCALELIST;R;Y;;-PURGE;A;*;N;-OVERKILL;ALL;;;FILTERS;

Now open the Keyboard Shortcuts -> Shortcuts Keys category in the top left window pane. Drag and drop your new Clean Drawing command up to and under the Shortcut Keys category.

We need to define a keystroke to activate our new command by using the CTRL key on the keyboard. Since we are defining the command though the CUI we have to do it this way. The other thing to watch out is there is a lot of keystrokes that have already been taken by AutoCAD so we are going to use CTRL  + U since it has not been used yet.

Now pick Ok on all of the dialog boxes and give it a try. If you don’t have Express Tools loaded you might get a message that the Overkill is an unknown command. If that happens, you can either go back and install them or just take out the Overkill command from the macro. Hope this helps keeping your drawings mean and clean going forward. See you in class, Jarod

This entry was posted in Autodesk AutoCAD Technology, Software Tips and Tricks. Bookmark the permalink.

Leave a Reply