×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

DUPLICATE ENTITIES REMOVAL LISP?

DUPLICATE ENTITIES REMOVAL LISP?

DUPLICATE ENTITIES REMOVAL LISP?

(OP)
...Long time ago I got involved with a drawing that had multiple entities for the same thing. Somebody had xref'd in or wblock the same thing in multiple times and this was on a large drawing file. The computer tech back then coughed up a LISP routine that looked at the start/stop pt.s and when it found multiple entities with the same point it would remove them ...worked slick! Well fast forward 8 yr.s & 3 jobs later, and I find myself with the same problem ...except on a VERY large drawing, and for the life of me I can't remember the name of the LISP routine! ...Can anybody help me here? ...OR introduce me to another way (or LISP) to eliminate these extra entities!!??  THX!   ...Mark

RE: DUPLICATE ENTITIES REMOVAL LISP?

Assuming you have Express Tools installed-

use the OVERKILL command.

RE: DUPLICATE ENTITIES REMOVAL LISP?

OVERKILL works well but if you don't have Express Tools try this :

CODE

;Tip1744:  CLEAR.LSP        Clear duplicates      (c)2001, ;Andrzej Gumula

(defun DXF (A) (cdr (assoc A (entget ONE)))) ;end dxf

(defun COMPLEX  ()
  (while (not (wcmatch (DXF 0) "*END*"))
    (setq ONE  (entnext ONE)
          ELEM (append ELEM (list ONE)))
    (CHECK)) ;end while
  ) ;end complex

(defun CORECT  (A)
  (cond ((= (type (cdr A)) 'list)
         (cons (car A) (mapcar '(lambda (X) (atof (rtos X 2 8))) (cdr A))))
        ((member (type (cdr A)) (list 'INT 'REAL))
         (cons (car A) (mapcar '(lambda (X) (atof (rtos X 2 8))) (list (cdr A)))))
        (t A))) ;end corect

(defun CHECK  ()
  (foreach X  (entget ONE)
    (if (not (member (car X) '(-2 -1 5 6 8 62 100)))
      (setq TEMP (cons (CORECT X) TEMP))))) ;end check

 ;(defun c:clear (/  CM LISTA NEW ONE TEMP OLD ZNACZNIK)
(defun C:CLEAR  ()
  (setq CM    (getvar "cmdecho")
        LISTA NIL
        NEW   NIL
        ONE   NIL
        TEMP  NIL
        OLD   (ssget "_X"))
  (setvar "cmdecho" 0)
  (cond
    (OLD
     (command "_-layer" "_u" "*" "")
     (prompt "\nDrawing clearing. ")
     (prompt "\nPlease wait... \n")
     (while (cond (ONE (setq ONE (entnext ONE)))
                  (t (setq ONE (entnext))))
       (setq ELEM (append ELEM (list ONE)))
       (CHECK)
       (if (or (and (= (DXF 0) "INSERT") (= (DXF 66) '1)) (= (DXF 0) "POLYLINE"))
         (COMPLEX))
       (if (member TEMP LISTA)
         (foreach X ELEM (entdel X)))
       (setq LISTA (cons TEMP LISTA)
             TEMP  NIL
             ELEM  NIL)
       (cond (ZNACZNIK (setq ZNACZNIK NIL) (princ "\r\\"))
             (t (setq ZNACZNIK (princ "\r/"))))) ;end while
     (prompt (strcat "\nNumber of elements before clearing- " (itoa (sslength OLD))))
     (prompt
       (strcat "\nNumber of elements after clearing- " (itoa (sslength (ssget "_X"))))))
    (t (prompt "\nFound zero elements. "))) ;end cond
  (setvar "cmdecho" CM)
  (princ)) ;end file
(prompt "\nLoaded new command CLEAR. ")
(princ)

____________________
Acad2005, Terramodel

RE: DUPLICATE ENTITIES REMOVAL LISP?

(OP)
Hey I want to thank both CarlB & lpseifert for the helpful advice here! I did have AutoCAD 2006 express tools but never knew of the "overkill" command ...till now. I tried that command on my drawing but it was so large it was grinding for some time before I had to escape from it. Then I tried lpseifert's Lisp routine, it's more basic and not as "harsh" ...When it's finished, then I try the overkill command to polish the drawing file. THX again!!!   ...Mark

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources