DWG File Size Reduction

How to Purge 50,000+ Orphaned Registered Applications (RegApps) via Command Line

Shrink bloated DWG files by 60%-90% and eliminate Xref lag by purging unreferenced AcDbRegAppTableRecord entries using -PURGE > R and batch AutoLISP scripts.

⚡ Quick Executive Fix

Notice that the standard graphical PURGE dialog (withouthyphen) historically skips Registered Applications! Always type -PURGE (with a leading hyphen), type R (Regapps), enter * for all, and type N to purge thousands of RegApps in seconds.

1. Engineering Root-Cause Diagnosis inside the AC1032 DWG Database

Every time a third-party vertical application, LISP utility, or BIM exporter attaches Extended Entity Data (`XDATA` group code `1001`) to an entity, it registers an application string inside the drawing's **`AcDbRegAppTable`**. When those entities are later erased or copied across Xrefs, the orphaned `AcDbRegAppTableRecord` entries remain behind—often accumulating **30,000 to 150,000 records** that bloat a simple 500 KB floor plan into a 35 MB file. Crucially, the standard graphical `PURGE` dialog does *not* list RegApps by default; you must invoke `-PURGE` → `Regapps`.

2. Step-by-Step Resolution Protocol in AutoCAD & GstarCAD 2027

1. Interactive Command-Line RegApp Purge (-PURGE > R)

Type -PURGE (include the leading minus sign), enter R (Regapps), press `Enter` to accept the `*` wildcard, and enter N (`No` to 'Verify each name to be purged?'). Watch the command history report `Purged 48,210 registered applications`.

2. Purge Nested Xrefs Before Attaching to Host Drawings

If a single attached civil Xref carries 40,000 unpurged RegApps, opening or copy-pasting from the host drawing can re-infect the project. Run `-PURGE > R` on all incoming consultant Xrefs before placing them in the Shared CDE folder.

3. Set ISAVEPERCENT = 0 to Compact Binary File Size on Save

After purging 50,000 RegApps, set ISAVEPERCENT = 0 before pressing `Ctrl+S` (`QSAVE`) so GstarCAD 2027 rewrites the entire AC1032 stream rather than leaving empty incremental-save padding inside the `.dwg`.

3. Automated AutoLISP Diagnostic & Repair Script (C:PURGEREGAPPS)

Load the following production AutoLISP routine into GstarCAD 2027 or AutoCAD via APPLOAD (or add it to gcaddoc.lsp) to automate this repair across affected project files:

(defun C:PURGEREGAPPS ( / doc regTable beforeCnt afterCnt)
  (vl-load-com)
  (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))
        regTable (vla-get-RegisteredApplications doc)
        beforeCnt (vla-get-Count regTable))
  (setvar "CMDECHO" 0)
  (command "_.-PURGE" "_Regapps" "*" "_No")
  (setvar "ISAVEPERCENT" 0)
  (setq afterCnt (vla-get-Count regTable))
  (princ (strcat "\n[PURGEREGAPPS] Purged " (itoa (- beforeCnt afterCnt))
                 " orphaned RegApps (" (itoa beforeCnt) " -> " (itoa afterCnt) ")."))
  (princ)
)

4. Diagnostic System Variables & Edge-Case Matrix

Failure Symptom / Scenario Command / SysVar Production Remediation Rule
Graphical PURGE dialog says 0 items to purge Use -PURGE (with hyphen) > R Only the command-line -PURGE exposes the Regapps (R) table option.
File size stays 30 MB even after -PURGE ISAVEPERCENT = 0 + QSAVE Forces full binary stream compaction instead of incremental save padding.
RegApps reappear every time drawing opens Clean Attached XREFs An attached Xref contains unpurged RegApps; run C:PURGEREGAPPS on the Xref.

Experience Faster, Corruption-Free DWG Engineering in GstarCAD 2027

Built by Suzhou Gstarsoft Co., Ltd. (SSE: 688657), GstarCAD 2027 features multi-threaded DWG open/save, built-in RegApp/Scale-List scrubbers, and perpetual licensing.

Download GstarCAD 2027 Free Trial → AutoCAD Migration Hub