;;; Select similar closed objects according to area
;;; Created by Lee Mac
;;; Saved from: https://www.cadtutor.net/forum/topic/61315-duplicate-polygons-total/?tab=comments#comment-506422

(defun c:ssa ( / cnt def ent ftr idx lst ss1 ss2 tar tol )

(setq tol 1e-6) ;; Tolerance for area comparison

(while (setq def (tblnext "layer" (not def)))
(if (or ( 0 (cdr (assoc 62 def)))
)
(setq lst (cons (cons 8 (cdr (assoc 2 def))) lst))
)
)
(cond
( (null
(setq ss1
(ssget "_X"
(setq ftr
(append
'( (0 . "CIRCLE,ELLIPSE,*POLYLINE,SPLINE")
(-4 . "<NOT")
(-4 . "")
(-4 . "NOT>")
(-4 . "<NOT")
(-4 . "<AND")
(0 . "ELLIPSE")
(-4 . "<OR")
(-4 . "") (41 . 0.0)
(-4 . "") (42 . 6.283185307179586)
(-4 . "OR>")
(-4 . "AND>")
(-4 . "NOT>")
)
(if lst (append '((-4 . "<NOT") (-4 . "") (-4 . "NOT>"))))
(if (= 1 (getvar 'cvport))
(list (cons 410 (getvar 'ctab)))
'((410 . "Model"))
)
)
)
)
)
)
(princ "\nNo valid objects found in the current layout.")
)
( (setq ss2 (ssget "_+.:E:S" ftr))
(setq tar (vlax-curve-getarea (ssname ss2 0)))
(repeat (setq idx (sslength ss1))
(setq ent (ssname ss1 (setq idx (1- idx))))
(or (equal tar (vlax-curve-getarea ent) tol)
(ssdel ent ss1)
)
)
(if (< 0 (setq cnt (1- (sslength ss1))))
(progn
(sssetfirst nil ss1)
(princ (strcat "\n" (itoa cnt) " other object" (if (= 1 cnt) "" "s") " with the same area found in the current space."))
)
(princ "\nNo other objects with the same area found in the current layout.")
)
)
)
(princ)
)
(vl-load-com) (princ)
(c:ssa)