this lisp will collect all the duplicate solids by volume and centroid and move them to layer to TODELETE.
the command: CLEANSOLIDS
Code:
;;;Select/delete duplicate 3d solid ... comparing SOLID volume and centroid all the match duplicates go-to layer TODELETE in red color.
;;;Delete solids could be activated.
;;;the solid volume and centroid had to be an exact match.
(vl-load-com) ;;; load ActiveX support
(setq *acadobj*(vlax-get-acad-object))
(setq *doc_ly*(vla-get-activedocument *acadobj*))
(setq *layers*(vla-get-Layers *doc_ly*))
;;;CREATE LAYER
(defun mk:layer (name color Linetype / clay nlayer)
(setq clay (getvar "clayer"))
(setvar "clayer" "0")
(setq nlayer(vlax-invoke-method *layers* 'Add name))
(vlax-put-property nlayer 'Freeze 0)
(vlax-put-property nlayer 'Lock 0)
(vlax-put-property nlayer 'LayerOn -1)
(if (= color nil)(setq color "7")(princ))
(vlax-put-property nlayer 'color color)
(if (= Linetype nil) (setq Linetype "Continuous") (princ))
(vlax-put-property nlayer 'Linetype Linetype)
(vla-Regen *doc_ly* acAllViewports)
(setvar "clayer" clay)
nlayer
)
;;;OBJECT volume and centroid LIST
(defun ob:vl:cn (ent / vlob vol cent)
(setq vlob(vlax-ename->vla-object ent))
(setq vol (vla-get-Volume vlob))
(setq cent(vlax-safearray->list(vlax-variant-value(vla-get-centroid vlob))))
(cons (cons vol cent) vlob )
)
(defun c:cleansolids (/ ent_list sld ssld del n ent ent_acc ent_list)
(mk:layer "TODELETE" 1 NIL)
(setq sld (ssget "_X" '((0 . "3DSOLID"))))
(setq ssld (sslength sld))
(setq del 0)
(setq n 0)
(repeat ssld
(setq ent (ssname sld n))
(setq ent_acc (ob:vl:cn ent))
(if (= (assoc (car ent_acc) ent_list) nil) ;;;check the volume and centroid
(setq ent_list (append ent_list (list ent_acc))) ;;;add the solid if the solid not in the list.
(progn
(vlax-put-property (vlax-ename->vla-object ent) 'LAYER "TODELETE");;;if the in the list, move the solid to layer "TODELETE"
;;; (vla-delete (vlax-ename->vla-object ent))
(setq del (1+ del))
)
)
(setq n (1+ n))
)
(prompt (strcat "\n" (rtos del 2 0) " Solids Deleted"))
(princ)
)