Code:
(vl-load-com)
(defun c:BadHatch (/ *error* acDoc bad ss)
(defun *error* (msg)
(if ss (vla-delete ss))
(cond ((not msg)) ; Normal exit
((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it
)
(princ)
)
(if (ssget "_x" (list '(0 . "HATCH") (cons 410 (getvar 'ctab))))
(progn
(setq bad (ssadd))
(vlax-for x (setq ss
(vla-get-activeselectionset
(setq acDoc (vla-get-activedocument
(vlax-get-acad-object)
)
)
)
)
(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-get-area (list x)))
(setq bad (ssadd (vlax-vla-object->ename x) bad))
)
)
(if (< 0 (sslength bad))
(sssetfirst nil bad)
(prompt "\nNo bad hatches found. \n")
)
)
)
(*error* nil)
)