;| Programmed by Dave Aguilar
DUPREM.LSP 1994 Onyx Software

This program creates an list of entity lists for all entities in the
drawing (using the first VERTEX for POLYLINES) and then compares each
entity list with the total list, building a new selection set of all
duplicate entries which are then erased.

it's not guarenteed but try it on a copy of a badly duplicated drawing
and see if it helps.

Modified by J. Tippit, SPAUG President 08/25/99
E-mail: jefft@iglobal.net
Web Site: http://www.spaug.org

1. Modified to work with R14 & 2000
2. Now prompts for 3 types of selection sets
3. Works on all types of entities (including LWPOLYLINES)

Large donations to SPAUG is appreciated. :)

(defun C:DUPREM ()
(setvar "cmdecho" 0)
(setq f1 nil f1 0)
; Added by Jeff Tippit 08/25/99
; Start
(initget "S L E")
(setq SLE (getkword "\nSelect objects by election set, imits, or ntire database: "))
((= SLE "S")(setq sa (ssget)))
((= SLE "L")(setq sa (ssget "c" (getvar "extmin")(getvar "extmax"))))
((= SLE "E")(setq sa (ssget "X")))
; End
(setq ca 0 ta (sslength sa) la nil lb nil)
(while (< ca ta)
(setq enta (ssname sa ca) ea (cdr (entget enta))
typa (cdr (assoc 0 ea))
; (if (= typa "POLYLINE") (progn
; (setq entb (entnext enta) ea (cdr (entget entb)))
; ))

; Added by Jeff Tippit 08/25/99
; Updated for R14 & 2000
; Start
(setq a1 (assoc 5 ea))
(setq a2 (cons 5 ""))
(setq ea (subst a2 a1 ea))
(if (wcmatch (getvar "ACADVER") "*15*")
(setq a3 (assoc 330 ea))
(setq a4 (cons 330 ""))
(setq ea (subst a4 a3 ea))
; End
(setq la (cons enta la) lb (cons ea lb)
ca (+ ca 1)
(setq sc nil sc (ssadd) ltest lb)
(setq ca 0)
(setq tes (car ltest) ltest (cdr ltest) ta nil ta (length ltest))
(while (/= ta 0)
(if (member tes ltest) (progn
(setq sc (ssadd (nth ca la) sc))
(prompt "\nFound duplicate entity.")
(setq f1 (+ f1 1))
(setq ca (+ ca 1))
(setq tes (car ltest) ltest (cdr ltest) ta (length ltest))
(command "erase" sc "")
(prompt "\n")(prin1 f1)(prompt " duplicate entities erased.")
(prompt "\nType DUPREM to run. Delete duplicate entity routine Ver 2.0 loaded.")