So you are looking for a utility that will move all duplicate entities to another layer rather than delete them, right?
Registered forum members do not see this ad.
Hi I need help from masters of LISP to a routine.
When I use the "overkill" command in Autocad, duplicate entities are deleted. Now, i want to a similar routine, which detects duplicate entities, but instead of deleting them, may be possible to save them in a selection or, as would be desirable to relate to a new layer.
As my knowledge is basic, I do not know how to solve. I appreciate the help.
So you are looking for a utility that will move all duplicate entities to another layer rather than delete them, right?
"I have only come here seeking knowledge. Things they wouldn't teach me of in college." The Police
Eat brains...gain more knowledge!
depending on what you mean by 'entity' you might be able to accomplish this through the filter command
If you would like to help my 2 year old niece Alaina in her battle against Leukemia you can donate blood at any Carter Blood Care and put SPON050875 on the donor form. Thank you so much for any contributions in this matter that you can make.
Luminous beings are we, not this crude matter.
This would be require a comparison routine using lists, a lot of list, but i think its doable
It gives me headache just by thinking about it
What about this approach <for LINE entities for now>
limited testing..
The line enitites are exact duplicates, granting all entity properties are "BYLAYER"Code:(defun c:test (/ objs i entN ent LineColl Entcoll LstR DupSS) (if (not (tblsearch "LAYER" "Duplicates")) (entmake (list (cons 0 "LAYER") (cons 100 "AcDbSymbolTableRecord") (cons 100 "AcDbLayerTableRecord") (cons 2 "Duplicates") (cons 62 2) (cons 70 0))) ) (setq objs (ssget '((0 . "*LINE,ARC,CIRCLE")))) (repeat (setq i (sslength objs)) (setq entN (ssname objs (setq i (1- i)))) (setq ent (entget entN)) (foreach itm '(-1 5 330 62) (setq ent (vl-remove (assoc (eval itm) ent) ent))) (setq LineColl (cons ent LineColl) EntColl (cons (list ent entN) Entcoll))) (setq DupSS (ssadd) lnt (length LineColl)) (while (setq a (car LineColl)) (setq b (cons a b) LineColl (vl-remove a (cdr LineColl))) (if (/= lnt (length LineColl)) (setq Dupss (ssadd (cadr (setq LstR (assoc a entcoll))) DupSS)) (setq lnt (length LineColl)) ) ) (command "_chprop" objs "R" Dupss "" "p" "Layer" "Duplicates" "") )
EDIT: after further testing, as it turned out it works for other entities as well... after seeing David's code i tried including arcs/polylines and circles in the selection...
Last edited by pBe; 3rd Sep 2011 at 01:12 pm.
Here could be the basic engine:
Each entity type would have it's own selection set ie SLINE for lines SARC for arcs etcCode:(defun c:finddup (/ ss dl en ed) (defun remove (expr lst);;;TonyT or VNesterowski (apply 'append (subst nil (list expr) (mapcar 'list lst)))) (foreach e '("ARC" "CIRCLE" "LINE" "POINT" "SOLID" "TRACE") (princ (strcat "\nSearching " e "s\n")) (if (setq ss (ssget "X" (list (cons 0 e)))) (progn (set (read (strcat "S" e)) (ssadd)) (setq dl nil) (while (setq en (ssname ss 0)) (princ "\r") (prin1 en) (setq ed (entget en)) (foreach g '(-1 5) (setq ed (remove (assoc g ed) ed))) (if (member ed dl) (ssadd en (eval (read (strcat "S" e)))) (setq dl (cons ed dl))) (ssdel en ss))))) (prin1))
You could probably add MTEXT LWPOLYLINE and a few other entity types. Heavy POLYLINEs and INSERTs with ATTRIButes would not work.
This will get very very slow on large drawings. -David
R12 (Dos) - A2K
This adds some of the other types
Code:(defun c:finddup (/ ss dl en ed) (defun remove (expr lst) ;;;REMOVE AN EXPRESSION FROM A LIST (apply 'append (subst nil (list expr) (mapcar 'list lst)))) ;;;TonyT or VNesterowski (foreach e '("3DFACE" "ARC" "ATTDEF" "CIRCLE" "LINE" "POINT" ;;;FOREACH SIMPLE ENTITY TYPE "SHAPE" "SOLID" "TRACE" "TEXT" "MTEXT" "LWPOLYLINE" "ELLIPSE") (princ (strcat "\nSearching " e "s\n")) ;;;DISPLAY ENTITY TYPE (setq dl nil) ;;;MAKE AN EMPTY COMPARISON LIST (and (setq ss (ssget "X" (list (cons 0 e)))) ;;;SEARCH FOR THIS ENTITY TYPE (set (read (strcat "S" e)) (ssadd)) ;;;MAKE A UNIQUE PICKSET FOR EACH ENTITY TYPE (while (setq en (ssname ss 0)) ;;;GET THE INITIAL PICKSET ENAME (princ "\r") (prin1 en) ;;;PROGRESS DISPLAY (setq ed (entget en)) ;;;GET THE ENTITY DEFINITION (foreach g '(-1 5) ;;;REMOVE THE ENAME (setq ed (remove (assoc g ed) ed))) ;;;AND HANDLE DATA (if (member ed dl) ;;;IF THE ENTITY DEFINITION IS A MEMBER OF THE COMPASSION LIST (ssadd en (eval (read (strcat "S" e)))) ;;;THEN ADD THE ENTITY TO THE DUPLICATE SET (setq dl (cons ed dl))) ;;;ELSE ADD THE DEFINITION TO THE COMPARISON LIST (ssdel en ss)))) ;;;REMOVE THE CURRENT INITIAL PICKSET ENAME (prin1)) ;;;EXIT CLEAN ;;;DUPLICATE PICKSET NAMES ARE GLOBAL ie SLINE SARC SCIRCLE
pBe, Thanks Just out of curiosity, why would you remove groups 330 and 62?
-David
Last edited by David Bethel; 4th Sep 2011 at 03:45 pm.
R12 (Dos) - A2K
Registered forum members do not see this ad.
Bookmarks