Thanks to all
So this is what it now looks like.......
;; CREDIT
https://www.theswamp.org/index.php?topic=1466.0;; This routine will rename all layout tabs in all open drawings
;; to "Layoutx" where x = the tab count
(defun c:re-name-all-layouts (/ Tab_name doc x cnt)
(vl-load-com)
(setq Tab_name "Layout")
(vlax-for doc (vla-get-documents (vlax-get-acad-object))
(setq cnt 0)
(vlax-for x (vla-get-layouts doc)
(if (not (= (vla-get-name x) "Model"))
(vla-put-name x
(strcat Tab_name (itoa (setq cnt (1+ cnt))))
)
)
)
)
)
;; CREDIT
https://www.theswamp.org/index.php?topic=53447.new#new(defun c:foo (/ a s sz tb)
(if (setq s (ssget "_x" '((0 . "insert") (2 . "A#_*") (410 . "~Model"))))
(foreach b (mapcar 'cadr (ssnamex s))
(setq a (cdr (assoc 330 (entget b)))
a (cdr (assoc 340 (entget a)))
a (vlax-ename->vla-object a)
tb (cdr (assoc 410 (entget b)))
sz (substr (cdr (assoc 2 (entget b))) 1 2)
)
(and (not (wcmatch tb "A#_*")) (vla-put-name a (strcat sz "_" tb)))
)
)
(princ)
)
(vl-load-com)
(defun C:LayTab ()
(C:re-name-all-layouts)
(c:foo)
)
(princ "\n\tre-name-all-layouts Loaded...........................Start command with LayTab.")
(princ)
(princ)