How to develop an AutoLISP routine to finish this task.
there might be some duplicate entities (sometimes, more than two entities) in some layers, how to remove the "duplicated" entities to another new layer and leave only one entity in the original layer, any reply would be appreciated!!! (sorry I am writing in English)
Actually Autocad has similar command---Overkill. This command can delete the duplicate entities. These are many topic about this issue in the forum. You can search it. Welcome.
thank u very much for ur reply, but my purpose is not to delete the duplicated entities, just cut them and paste them to a new layer. have any idea about this?
This is a program about delete duplicated circle,pl,line,spline, block.
Maybe you can get some hint from it. You can revise it to suit your need.
(defun C:DUP (/ F1 SLE SA CA TA LA LB ENTA EA TYPA A1 A2 A3 A4 SC LTEST TES ) (setvar "cmdecho" 0) (setq F1 NIL F1 0 )
;; Start (or :GCHOICE (setq :GCHOICE "Select")) (initget "Select All") ;;; (setq SLE (getkword "\nSelect objects by <S>election set, <L>imits, or <E>ntire database: ")) (setq SLE (getkword (strcat "\nType of selection [Select/All] <" :GCHOICE ">: " ) ) ) (if (not SLE) (setq SLE :GCHOICE) (setq :GCHOICE SLE) ) (cond ((= SLE "Select") (setq SA (ssget))) ((= SLE "Limits") (setq SA (ssget "c" (getvar "extmin") (getvar "extmax"))) ) ((= SLE "All") (setq SA (ssget "X"))) )
(if (and SA (= (type SA) 'PICKSET) (not (zerop (sslength SA)))) (progn (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))) ;; ))
;; Updated for R14 & 2002 ;; Start (setq A1 (assoc 5 EA)) (setq A2 (cons 5 "")) (setq EA (subst A2 A1 EA)) (if (wcmatch (getvar "ACADVER") "*15*") (progn (setq A3 (assoc 330 EA)) (setq A4 (cons 330 "")) (setq EA (subst A4 A3 EA)) ) )
(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 "") (redraw) (prompt "\n") (prin1 F1) (prompt " duplicate entities erased.") ) ) (princ) ) (prompt "\nType DUP to run. Delete duplicate entity routine." ) (princ)