+ Reply to Thread
Page 1 of 7 1 2 3 ... LastLast
Results 1 to 10 of 66
  1. #1
    Senior Member teknomatika's Avatar
    Using
    AutoCAD 2009
    Join Date
    Sep 2010
    Location
    Portugal
    Posts
    206

    Default Help - Select duplicate entities

    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.

  2. #2
    Quantum Mechanic ReMark's Avatar
    Computer Details
    ReMark's Computer Details
    Operating System:
    Windows 7 Pro 64-bit
    Computer:
    Thinkmate
    Motherboard:
    Intel DX58SO2 LGA1366 X58
    CPU:
    Intel i7-960 Quad-core 3.20GHz 8MB cache
    RAM:
    12GB (3x4GB) PC3-106000 DDR3
    Graphics:
    nVidia Quadro 4000, 2GB GDDR5
    Primary Storage:
    150GB Velocipraptor 10,000 rpm
    Secondary Storage:
    none
    Monitor:
    Dell P24LLH - 24" wide screen LCD
    Discipline
    See details...
    ReMark's Discipline Details
    Occupation
    CAD Draftsman/Designer...chemical manufacturing.
    Discipline
    See details below.
    Details
    I work for a specialty chemical manufacturer. I do a little bit of everything from P&IDs to civil to architectural and structural.
    Using
    AutoCAD 2013
    Join Date
    Nov 2005
    Location
    Norwalk, CT USofA
    Posts
    33,457

    Default

    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!

  3. #3
    Senior Member teknomatika's Avatar
    Using
    AutoCAD 2009
    Join Date
    Sep 2010
    Location
    Portugal
    Posts
    206

    Default

    Quote Originally Posted by ReMark View Post
    So you are looking for a utility that will move all duplicate entities to another layer rather than delete them, right?
    ReMark, Yes, that's it.
    I want to take duplicate entities, to give them a specific use.

  4. #4
    Super Member DANIEL's Avatar
    Discipline
    Mechanical
    DANIEL's Discipline Details
    Occupation
    Industrial
    Discipline
    Mechanical
    Using
    AutoCAD 2013
    Join Date
    May 2005
    Location
    Arlington Texas
    Posts
    1,001

    Default

    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.

  5. #5
    Senior Member teknomatika's Avatar
    Using
    AutoCAD 2009
    Join Date
    Sep 2010
    Location
    Portugal
    Posts
    206

    Default

    Quote Originally Posted by DANIEL View Post
    depending on what you mean by 'entity' you might be able to accomplish this through the filter command
    Daniel:Any and all AutoCAD entities: lines, polylines, arcs, circles, points, text, etc..
    For what I want, it would be good to consider at least the lines.
    With the command filter, do not seem to select only those entities duplicate.

  6. #6
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,152

    Default

    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..

    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"
                "")
          )
    The line enitites are exact duplicates, granting all entity properties are "BYLAYER"

    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.

  7. #7
    Super Member David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    1,926

    Default

    Here could be the basic engine:

    Code:
    (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))
    Each entity type would have it's own selection set ie SLINE for lines SARC for arcs etc

    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

  8. #8
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,152

    Default

    Quote Originally Posted by David Bethel View Post
    Here could be the basic engine:
    Brilliant David, I had the same general idea but cant quite make the removal as efficient as yours

    BTW: This...
    Quote Originally Posted by David Bethel View Post
    (defun remove (expr lst);;;TonyT or VNesterowski
    (apply 'append (subst nil (list expr) (mapcar 'list lst))))

  9. #9
    Super Member David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    1,926

    Default

    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

  10. #10
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,152

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by David Bethel View Post
    pBe, Thanks Just out of curiosity, why would you remove groups 330 and 62?
    -David
    Oh that.. forgot to remove it while testing the code, trying to exclude entities with assigned color, same thing for 330, forgot to remove that as well while testing for attached image and xref, but its apparent that theres no need for that too.

Similar Threads

  1. Combine 2 lisps to select last n entities drawn
    By flopo in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 3rd Jul 2011, 03:44 pm
  2. Replies: 2
    Last Post: 11th Nov 2010, 10:53 am
  3. Can't Select Entities at Non-Zero Elevation
    By Schumi in forum AutoCAD Bugs, Error Messages & Quirks
    Replies: 1
    Last Post: 12th May 2009, 12:31 am
  4. Req: How to select all entities in a layer? [VBA]
    By theone in forum AutoLISP, Visual LISP & DCL
    Replies: 15
    Last Post: 7th Jul 2008, 09:42 am
  5. Delete duplicate entities
    By mazucals in forum AutoLISP, Visual LISP & DCL
    Replies: 12
    Last Post: 11th Jul 2007, 08:41 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts