Hello!
I've got a routine I use to rename layout tabs to the number of the position they're in, but I'm having trouble modifying it to a new standard.
I have layout tabs named something like "CB-05-Overview ISO" or "SS-10-Counter". I'd like to rename the layout tabs so each layout that starts with "CB" has the following number in order, counting up from 01. So if there were only 1 layout that starts with CB, then my above example would turn it into "CB-01-Overview ISO". Then I'd like to repeat this with other formats (i.e., "CB", "SS", "SI"...) (hence the COND statement).
This is the code I've been fiddling with, but I can't seem to get it to work (or see what's exactly wrong with it). Would someone be kind enough to give me some direction?
(defun RenameLayouts (/ acDoc)
(defun *error* (msg)
(if acDoc
(vla-endundomark acDoc)
)
(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)
)
(vla-startundomark
(setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
)
(vlax-for x (vla-get-layouts acDoc)
(cond
(
(and
(/= (vla-get-name x) "Model") ; not model tab
(= (vla-get-name x) "CB-*") ; construction/build tab
)
(vla-put-name x (strcat "CB-" (itoa (vla-get-taborder x)) (itoa (vl-string-subst x 5))))
)
(t (princ "Nope."))
)
)
(*error* nil)
)
Thanks for the help