|

OverkillLite: The High-Speed Duplicate Remover for Large AutoCAD Drawings

Program Description

OverkillLite (OKL) is a streamlined AutoLISP utility built to eliminate the performance issues tied to the native OVERKILL command in AutoCAD. The standard tool runs deep geometric comparisons, including partial overlaps and tolerance-based merging. That level of analysis is expensive. On large drawings—especially anything above 50,000 entities—it often leads to freezes, long processing times, or crashes.

OverkillLite takes a different path. Instead of evaluating geometry relationships in real time, it generates a unique digital signature for each entity based on:

  • Object type (LINE, ARC, etc.)
  • Layer
  • Geometry (coordinates, radius, angles, text content, etc.)

These signatures are processed using a high-speed sorting algorithm (O(N log N)), allowing the routine to identify and remove exact 1:1 duplicates in a single pass.

No tolerance guessing. No geometry merging. Just clean, predictable results.

This makes OKL particularly effective when dealing with:

  • PDF imports that stack duplicate geometry
  • Exploded blocks with repeated entities
  • Large site plans and masterplans
  • Legacy drawings with accumulated duplication

How to Fix AutoCAD Freezing During OVERKILL Command

If you’ve ever launched OVERKILL on a heavy file and watched AutoCAD lock up, the pattern is consistent:

  • OVERKILL evaluates partial overlaps
  • It runs tolerance-based comparisons
  • It performs pairwise checks (O(N²))

That combination slows everything down.

OverkillLite avoids all of it.

Instead of interpreting geometry relationships, it:

  1. Converts every object into a deterministic signature
  2. Sorts the dataset once
  3. Removes duplicates in a linear pass

Result:

  • No freezing
  • No waiting
  • No geometry risk

Download the script here.


Step-by-Step Guide: How to Use OKL

1. Load the Script

Save the file as:

OverkillLite.lsp

Load it using:

  • Drag & drop into AutoCAD
  • Or run APPLOAD

Reference: https://help.autodesk.com/view/ACD/2024/ENU/?guid=GUID-APPLOAD


2. Launch the Command

OKL

3. Select Objects

  • Select specific objects
  • Or press Enter → processes the entire drawing

4. Automatic Processing

The routine executes:

  1. Signature extraction
  2. Sorting (O(N log N))
  3. Duplicate detection (adjacent comparison)
  4. Deletion

No dialog. No parameters.


5. Review Results

Command line output:

  • Number of deleted duplicates
  • Or confirmation that none were found

Full AutoLISP Program (OverkillLite.lsp)

;;; OverkillLite.lsp
;;; Command: OKL
;;; Description: Fast removal of exact duplicate objects.
;;; It bypasses partial overlap checks in favor of a high-speed signature sorting algorithm.

(defun c:OKL (/ ss i ent edata sigList sortedList prevSig currentSig delList delCount 
              rtos_prec round_pt make_sig)
  (vl-load-com)

  ;; Set coordinate precision for matching (4 decimal places is standard)
  (setq rtos_prec 4)

  ;; Helper Function: Formats coordinates into a tight string
  (defun round_pt (pt)
    (if (and pt (listp pt) (>= (length pt) 2))
      (strcat (rtos (car pt) 2 rtos_prec) "," 
              (rtos (cadr pt) 2 rtos_prec) "," 
              (if (caddr pt) (rtos (caddr pt) 2 rtos_prec) "0.0000"))
      "0,0,0"
    )
  )

  ;; Helper Function: Generates a unique string signature for an entity
  (defun make_sig (ent / edata etype lay sig p1 p2 rad txt name pts)
    (setq edata (entget ent))
    (setq etype (cdr (assoc 0 edata)))
    (setq lay (cdr (assoc 8 edata)))

    (cond
      ;; LINES
      ((= etype "LINE")
        (setq p1 (cdr (assoc 10 edata)))
        (setq p2 (cdr (assoc 11 edata)))
        ;; Sort points so lines drawn A->B and B->A have the same signature
        (if (or (< (car p1) (car p2)) 
                (and (= (car p1) (car p2)) (< (cadr p1) (cadr p2))))
          (setq sig (strcat etype "_" lay "_" (round_pt p1) "_" (round_pt p2)))
          (setq sig (strcat etype "_" lay "_" (round_pt p2) "_" (round_pt p1)))
        )
      )
      ;; CIRCLES
      ((= etype "CIRCLE")
        (setq p1 (cdr (assoc 10 edata)))
        (setq rad (cdr (assoc 40 edata)))
        (setq sig (strcat etype "_" lay "_" (round_pt p1) "_" (rtos rad 2 rtos_prec)))
      )
      ;; ARCS
      ((= etype "ARC")
        (setq p1 (cdr (assoc 10 edata)))
        (setq rad (cdr (assoc 40 edata)))
        (setq sig (strcat etype "_" lay "_" (round_pt p1) "_" (rtos rad 2 rtos_prec) "_" 
                          (rtos (cdr (assoc 50 edata)) 2 rtos_prec) "_" 
                          (rtos (cdr (assoc 51 edata)) 2 rtos_prec)))
      )
      ;; TEXT & MTEXT
      ((or (= etype "TEXT") (= etype "MTEXT"))
        (setq p1 (cdr (assoc 10 edata)))
        (setq txt (cdr (assoc 1 edata)))
        (setq sig (strcat etype "_" lay "_" (round_pt p1) "_" txt))
      )
      ;; BLOCKS (INSERT)
      ((= etype "INSERT")
        (setq p1 (cdr (assoc 10 edata)))
        (setq name (cdr (assoc 2 edata)))
        (setq sig (strcat etype "_" lay "_" (round_pt p1) "_" name))
      )
      ;; POLYLINES
      ((= etype "LWPOLYLINE")
        ;; Extract all vertices (assoc 10)
        (setq pts (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) edata)))
        (setq sig (strcat etype "_" lay "_" (itoa (cdr (assoc 90 edata)))))
        (foreach pt pts 
          (setq sig (strcat sig "_" (round_pt pt)))
        )
      )
      ;; FALLBACK (Other entity types)
      (t
        (setq p1 (cdr (assoc 10 edata)))
        (if p1
          (setq sig (strcat etype "_" lay "_" (round_pt p1)))
          (setq sig (strcat etype "_" lay "_" (vl-princ-to-string ent)))
        )
      )
    )
    sig
  )

  ;; Main Routine execution
  (princ "\nSelect objects for OverkillLite (Press Enter for ALL): ")
  (if (null (setq ss (ssget)))
    (setq ss (ssget "X"))
  )

  (if ss
    (progn
      (princ "\nAnalyzing geometry... please wait.")
      (setq i 0 sigList nil)

      ;; 1. Extract signatures
      (while (< i (sslength ss))
        (setq ent (ssname ss i))
        (setq sigList (cons (cons ent (make_sig ent)) sigList))
        (setq i (1+ i))
      )

      ;; 2. Sort alphabetically by signature (This is what makes it lightning fast)
      (setq sortedList (vl-sort sigList '(lambda (a b) (< (cdr a) (cdr b)))))

      ;; 3. Find and group exact duplicates
      (setq prevSig "" delList nil)
      (foreach item sortedList
        (setq currentSig (cdr item))
        (if (= currentSig prevSig)
          (setq delList (cons (car item) delList))
          (setq prevSig currentSig)
        )
      )

      ;; 4. Delete the duplicates
      (setq delCount 0)
      (if delList
        (progn
          (foreach ent delList
            (entdel ent)
            (setq delCount (1+ delCount))
          )
          (princ (strcat "\nSuccess: Deleted " (itoa delCount) " exact duplicate object(s)."))
        )
        (princ "\nResult: No exact duplicates found.")
      )
    )
    (princ "\nNo objects selected.")
  )
  (princ)
)

(princ "\n>> OverkillLite loaded. Type OKL to run. <<")
(princ)

How OverkillLite Works (Under the Hood)

Signature-Based Detection

Each entity is converted into a string signature, for example:

LINE_Layer1_0,0,0_100,0,0

For LINE objects:

  • Endpoints are normalized so A→B and B→A produce the same signature
  • Points are sorted by coordinates (X first, then Y) before generating the string

Sorting Instead of Pairwise Comparison

Standard approach:

  • Compare everything → O(N²)

OKL approach:

  • Sort once → O(N log N)
  • Compare neighbors only

Precision Control

Coordinates are rounded to 4 decimal places:

  • Avoids floating errors
  • Keeps signatures consistent

SEO Optimization & Performance Benefits

Using a lightweight Overkill LISP is standard practice when optimizing drawings.

Benefits:

  • Geometry integrity preserved
  • Reduced entity count
  • Faster REGEN
  • Smaller DWG size
  • Cleaner plotting output

Especially useful in:

  • Civil 3D
  • AutoCAD Map 3D

Compatibility (AutoCAD Versions)

  • AutoCAD 2020 → 2026
  • Forward compatible (standard AutoLISP)

Why Choose OverkillLite Over Standard OVERKILL?

FeatureNative OVERKILLOverkillLite
SpeedSlowUltra-fast
StabilityCan crashStable
DetectionPartial overlapsExact duplicates only
RiskGeometry changesSafe
WorkflowInteractiveOne command

When NOT to Use OverkillLite

Does not:

  • Merge collinear lines
  • Detect overlaps
  • Simplify geometry

Use it for fast cleanup only.


Field Notes from Production Use

  • PDF cleanup → 30–70% reduction
  • Large files → seconds execution
  • Real case:
    • 15 minutes → 10 seconds on a 150MB master plan

Workflow:

  1. Run OKL
  2. Then OVERKILL if needed

External References


FAQ

What does OverkillLite remove?

Only exact duplicates.


Does it modify geometry?

No.


Why is it faster?

Uses sorting instead of pairwise comparison.


Large drawings?

Yes, built for them.


Polylines?

Based on vertex order.

  • Reversed polylines → NOT detected as duplicates

Blocks?

Detects duplicate INSERTs only.


Tolerance?

Controlled via rounding precision.


Replace OVERKILL?

No. Use both depending on need.