;; Copy First Layout Multiple Times and Number Incrementally
;; Saved from: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/copy-first-layout-multiple-times-and-number-incrementally/td-p/7030955
;; Created by Ranjit.Singh
;; Slightly modified by Igal Averbuh 2017 (added layout sort function)

(defun C:TabSort (/ cnt doc lay)
(vl-load-com)
(setq cnt 1
doc (vla-get-activedocument (vlax-get-acad-object))
)
(foreach lay (acad_strlsort (vl-remove "Model" (layoutlist)))
(vla-put-taborder (vla-item (vla-get-layouts doc) lay) cnt)
(setq cnt (1+ cnt))
)
(princ)
)

(defun c:cll (/ a adoc curpos curtab i n)
(setvar "tilemode" 0)
(and (= 0 (getvar 'tilemode))
(setq i (getint "\nEnter Starting Layout number: ")
curtab (substr (getvar 'ctab) 1 (- (strlen (getvar 'ctab)) 2))
n (getint "\nHow many copies of this tab: "))
(repeat n
(command "._layout" "_copy" "" (strcat curtab (if (= 1 (strlen (setq a (itoa (+ (1- n) i)))))
(strcat "0" a)
a)))
(setq i (1- i)))))

(defun c:cl (/)
(c:cll)
(C:TabSort)
)
(c:cl)

Advertisements