MarsByr Posted March 12, 2021 Posted March 12, 2021 (edited) Hello, I have a lisp that renames all my tabs from whatever nale theay have at the time to sequential numerical order (Model, 01,02,03, etc.) I didn't write it and don't understand the code, but it works fine. My title block uses the tab name as part of the drawing number, so this works great for me. After model Tab though (which is ignored), before layouts 01, 02, etc. I want to have 'Cover' and 'ToC' before 01,02, etc. So what I am saying is that I want these tabs to be ignored not renamed. To get around this at th emoment I move the Cover and Table of Contents (ToC) tab to the end of the tabs, renumber all with the lisp then move CoV and ToC back to the start and retype the names in. That becomes a bit of a pain, as is I add one drawing into a set or change the order, then I have to redo that process. I am then left with Model, Cov, ToC, 01, 02, 03, etc. I hope I made that clear. Can anyone edit the lisp code so that it ignores either the first 2 layouts before it starts numbering the tabs, or better still ignores the tab names that I want to be ignored if the tab names are typed into the lisp? Thank you (defun c:foo (/ a i l p x) ;; Get layouts (vlax-for x (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (setq l (cons x l))) ;; Sort by taborder and remove model tab (setq l (cdr (vl-sort l '(lambda (a b) (< (vla-get-taborder a) (vla-get-taborder b)))))) ;; Set counter (setq i 0) ;; Temporarily number them so we don't get duplicates (foreach x l (setq i (1+ i)) (vla-put-name x (strcat "FooTempBazoom_" (itoa i)))) ;; Set counter (setq i 0) ;; Get the layout count string length so we can add 0's if needed (setq a (strlen (itoa (length l)))) (foreach x l ;; Increment counter (setq i (1+ i)) ;; Reset prefix (setq p "") ;; Add zeroes to prefix if any (repeat (- a (strlen (itoa i))) (setq p (strcat p "0"))) ;; Change the tab name (vla-put-name x (strcat p (itoa i))) ) (command "regenall") (princ) ) (vl-load-com) Edited March 12, 2021 by SLW210 Added Code Tags Quote
MarsByr Posted March 12, 2021 Author Posted March 12, 2021 Or maybe even easier - just renames the selected tabs perhaps? Quote
tombu Posted March 12, 2021 Posted March 12, 2021 Just a suggestion. I used Lee Mac's lfnumber function from http://lee-mac.com/layoutfield.html which is loaded by acaddoc.lsp to set sheet number in my template's layout title block. It generates a field expression referencing the position of the layout in which the selected annotation object resides. If I drag the layout tabs around my sheet numbers are automatically renumbered to always be numbered consecutively left to right in order. I use the layout tab names as sheet descriptions which are also referenced in the title block and make finding what you're looking for in a set of plans a lot easier. 1 Quote
ronjonp Posted March 12, 2021 Posted March 12, 2021 (edited) Try this simple mod: (defun c:foo (/ a i l p x) ;; Get layouts (vlax-for x (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (setq l (cons x l))) ;; Sort by taborder and remove model tab (setq l (cdr (vl-sort l '(lambda (a b) (< (vla-get-taborder a) (vla-get-taborder b)))))) ;; Remove the first two tabs from the list if the names match "COV,TOC" (repeat 2 (and (car l) (wcmatch (strcase (vla-get-name (car l))) "COV,TOC") (setq l (cdr l)))) ;; Set counter (setq i 0) ;; Temporarily number them so we don't get duplicates (foreach x l (setq i (1+ i)) (vla-put-name x (strcat "FooTempBazoom_" (itoa i)))) ;; Set counter (setq i 0) ;; Get the layout count string length so we can add 0's if needed (setq a (strlen (itoa (length l)))) (foreach x l ;; Increment counter (setq i (1+ i)) ;; Reset prefix (setq p "") ;; Add zeroes to prefix if any (repeat (- a (strlen (itoa i))) (setq p (strcat p "0"))) ;; Change the tab name (vla-put-name x (strcat p (itoa i))) ) (command "regenall") (princ) ) (vl-load-com) Edited March 12, 2021 by ronjonp Quote
MarsByr Posted May 9, 2021 Author Posted May 9, 2021 Thank you all for your responses which are most helpful to me. My apologies for the slow response - I have been a bit inundated of late so have got back to this now I have a free Sunday. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.