;;; Numbering Layouts with save Previous Layout name (with option to add prefix and suffix to existing Layout Name)
;;; Based on http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/autolisp-renaming-tabs/m-p/6360355#U6360355
;;; Little modified by Igal Averbuh 2016

(vl-load-com)

(defun c:SLT (/ *error*)

(defun *error* (msg)
(if acDoc
(vla-endundomark acDoc)
)
(cond ((not msg)) ; Normal exit
((member msg '("Function cancelled" "quit / exit abort"))) ; or (quit)
((princ (strcat "\n** Error: " msg " ** ")))
) ; Fatal error, display it
(princ)
)

((lambda (acDoc / prefix i suffix delin)
(vla-startundomark acDoc)
(if
(and
(or (setq prefix (getstring T "\nEnter layout tab prefix: "))
(setq prefix "")
)
(not (initget 5))
(setq i (1- (getint "\nEnter starting number: ")))
(if
(/= ""
(setq suffix (getstring T "\nEnter layout tab suffix: "))
)
(setq suffix (strcat "-" suffix))
(setq suffix (strcat ""))
)
)
(progn
(foreach x (layoutlist)
(vla-put-name
(vla-item (vla-get-layouts acDoc) x)
; (strcat prefix (itoa (setq i (1+ i))) suffix)

(strcat prefix (itoa (setq i (1+ i))) " "
(if (wcmatch x "#* *")
(substr x (+ 3 (vl-string-position 32 x)))
x) suffix)

)
)
(*error* nil)
)
(*error* "Must enter start of sequence")
)
)
(vla-get-activedocument (vlax-get-acad-object))
)
)
(c:SLT)

Advertisements