AutoCAD Duplicate Object Cleanup & Shortcut Key Setup Using LISP



AutoCAD · LISP

In mechanical design, a surprisingly large amount of time gets wasted on drawing cleanup. This is especially true when working with drawings received from other companies, or assembly drawings that have been revised many times — overlapping lines bloat the file size and cause issues like failed hatching.

“Why is this drawing so heavy? And why won’t the hatch go in…”

Today I’m sharing two powerful LISP scripts and shortcut tips that mechanical design professionals use every day to get off work on time.


1. Put Your Drawing on a Diet — Auto-Delete Duplicate Objects (OVERKILL)

As you draw, it’s easy to accidentally stack lines on top of each other without noticing. This is especially common when flattening 3D drawings to 2D — the overlap can be massive. AutoCAD’s built-in OVERKILL command merges and removes these duplicates, making your drawing significantly lighter. The problem is that the default command prompts you with an options dialog every time, which gets tedious.

The LISP below assigns a short alias that instantly cleans the entire drawing with no prompts.

(defun c:OK ()
  (command "-OVERKILL" "ALL" "" "")
  (princ "\n=== Duplicate object cleanup complete ===")
  (princ)
)
  • Shortcut: OK (feel free to change it to anything you like)
  • How to use: Load the LISP, then type OK in the command line and press Enter. It will scan every object on screen and automatically remove all overlapping lines.
  • Benefits: Reduces DWG file size, prevents hatch errors, eliminates duplicate line weight issues when plotting

2. Two Ways to Shorten Those Long Dimension Shortcuts

Dimensioning is one of the most-used functions when drafting. But the default shortcuts — DLI for DIMLINEAR and DAL for DIMALIGNED — feel a bit long when you’re typing them dozens of times a day. Here are two ways to shorten them to something like D1 or D2.

Method A: Edit the acad.pgp Shortcut File

AutoCAD manages all keyboard shortcuts through a file called acad.pgp. A small edit here lets you remap any command to whatever alias you want.

  • Step 1: Go to Tools > Customize > Edit Program Parameters (acad.pgp) from the top menu. (Or type ALIASEDIT in the command line.)
  • Step 2: A Notepad file will open. Scroll down to find the shortcut alias list.
  • Step 3: Find the dimension commands you want to change, or add new ones at the bottom. The format is alias, *COMMAND.

    [Recommended dimension shortcut setup]

    D1, *DIMLINEAR   ;; Linear dimension
    D2, *DIMALIGNED  ;; Aligned dimension
    D3, *DIMANGULAR  ;; Angular dimension
    D4, *DIMRADIUS   ;; Radius dimension
  • Step 4: Save the file (Ctrl+S) and close Notepad.
  • Step 5: Type REINIT in the command line, check the PGP file option, and click OK — or simply restart AutoCAD. Your new shortcuts are ready.

Method B: Define Shortcuts Directly in LISP (Strongly Recommended ✨)

Editing acad.pgp works fine, but in practice your settings often get wiped — after a reformat, a fresh AutoCAD install, working on a colleague’s machine, or sharing setups across a team. Re-entering your shortcuts in acad.pgp every time is a pain.

If you define your shortcuts inside a LISP file instead, all you need is that one file on a USB drive. Your custom shortcuts are instantly available on any machine, anytime.

;; Dimension shortcut LISP setup
(DEFUN C:D1  () (command "dimlinear"))    ;; Linear dimension
(DEFUN C:D2  () (command "dimaligned"))   ;; Aligned dimension
(DEFUN C:D3  () (command "dimangular"))   ;; Angular dimension
(DEFUN C:D4  () (command "dimradius"))    ;; Radius dimension
(DEFUN C:D5  () (command "dimdiameter"))  ;; Diameter dimension

📌 Wrapping Up — How to Load and Register Your LISP

Copy both scripts above (the OVERKILL cleaner and the dimension shortcuts) into a single Notepad file and save it with a .lsp extension (e.g., acadset.lsp). You can load it by dragging and dropping the file onto the AutoCAD canvas, or by typing APPLOAD in the command line and adding the file to the Startup Suite. Once registered there, your custom shortcuts and LISP routines will load automatically every time AutoCAD starts.

💡 Pro Tip from Donaenam: The Setup That Saves Your Evenings

After calculating cylinder forces and finalizing a mechanism design, the last thing you want is to spend an hour cleaning up drawings. These tools will become your quiet, reliable assistants during that final push. This is the exact LISP and shortcut setup I use every single day in production. Give it a try — and here’s to leaving the office on time.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top