Maybe something like
(defun c:LayIso (/ ss Ent Str LayName)
(setq Str "")
(if (setq ss (ssget))
(while (setq Ent (ssname ss 0))
(if (not (vl-string-search (setq LayName (cdr (assoc 8 (entget Ent)))) Str))
(if (= Str "")
(setq Str LayName)
(setq Str (strcase Str ", " LayName))
)
)
(ssdel Ent ss)
)
)
(if Str
(command "_.layer" "_set" LayName "_off" "*" "_no" "_on" Str "")
)
(princ)
)