How can I remove same object of repeat by lisp?

How can I remove same object of repeat by lisp?

skchui6159
Advocate Advocate
1,141 Views
7 Replies
Message 1 of 8

How can I remove same object of repeat by lisp?

skchui6159
Advocate
Advocate

Same as topic.

skchui6159_0-1738895907011.png

Can a lisp can erase the repeated object (SAME COORDINATE, SAME SIZE , SAME PROPERTIES...)in AUTOCAD? Thankz.

0 Likes
Accepted solutions (1)
1,142 Views
7 Replies
Replies (7)
Message 2 of 8

paullimapa
Mentor
Mentor

How's about SelectSimilar?

paullimapa_0-1738910437898.png

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 8

skchui6159
Advocate
Advocate

@paullimapa Sorry, It should be keep 1 of the object, other should be erase. One object in same location should be kept one. Other object should be erase.

0 Likes
Message 4 of 8

cadffm
Consultant
Consultant
Accepted solution

Programming:

Compare all objectdata of all object, delete all similars but one.

 

LazyDrafter:

Runs OVERKILL [F1]

 

LazerProgrammer:

Controles -OVERKILL [F1] by command-statement.

Sebastian

Message 5 of 8

skchui6159
Advocate
Advocate

@cadffm Thank a lot!

0 Likes
Message 6 of 8

paullimapa
Mentor
Mentor

Before running Overkill I see 4 objects looking like this:

paullimapa_1-1738947490103.png

 

After running Overkill I see 1 object looking like this:

paullimapa_0-1738947455565.png

 

You can also try this code and enter at the command prompt: REM

 

; rem function removes duplicates but keeps the one initially selected
; OP:
; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-can-i-remove-same-object-of-repeat-by-lisp/m-p/13305272#M478451
(defun c:rem (/ ss)
 (if (setq ss (ssget "_+.:E:S"))
  (progn 
   (command "_.selectsimilar" ss "")
   (if (ssget "_P")
    (progn
     (command "_.Erase" "_P" "_R" (ssname ss 0) "")
     (sssetfirst nil ss)
    )
   )
  )
 )  
 (princ)
)

 

 

Afterwards you should see only 1 object looking like this:

paullimapa_2-1738947586333.png

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 7 of 8

skchui6159
Advocate
Advocate

Thank you very much, it is the upgrade function of select similar.

0 Likes
Message 8 of 8

paullimapa
Mentor
Mentor

You are welcome…cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes