ILoveMadoka Posted June 6, 2022 Posted June 6, 2022 I use Alan's code shown here: Original Code ;; Zoom extents in All Layouts (excluding Model) ;; Alan J. Thompson (or *Acad* (setq *Acad* (vlax-get-acad-object))) (or *AcadDoc* (setq *AcadDoc* (vla-get-activedocument *Acad*))) ((lambda (ctab) (foreach layout (layoutlist) (setvar 'ctab layout) (vla-put-mspace *AcadDoc* :vlax-false) (vla-zoomextents *Acad*) ) (setvar 'ctab ctab) ) (getvar 'ctab) ) (princ) It works perfectly and returns you to the Layout/Current Tab you started the command in each time How can I get this to go to the very first tab prior to running the code? (or afterwards - either way) Looking around I found this code which returns a list of tabs but I do not know how to set Tab number 1 to be the current tab (vlax-for lay (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (setq lst (cons (list (vla-get-taborder lay)(vla-get-name lay)) lst)) ) Wanting to show that I'm at least "trying" I know that there is this: (command "Layout" "Set" "X") ;; Solve for X I'm sure this is much easier than I'm making it.. Quote
ILoveMadoka Posted June 6, 2022 Author Posted June 6, 2022 Is there a simple statement for going to the very first tab? I have other routines I'm working on that need that as well... Quote
mhupp Posted June 6, 2022 Posted June 6, 2022 (edited) From here. The original lisp build a list of tabs and sorted them from the 71 dxf code left to right. modified it to just look for the first tab and set it as current Modified it to look for the tab # user defines and set it to current tab. (defun TAB (x / laylst tab lay) (setq laylst (massoc 350 (dictsearch (namedobjdict) "acad_layout"))) (foreach tab laylst (setq lay (entget tab)) (if (eq x (cdr (assoc 71 lay))) ;made it dynamic (setvar 'ctab (last (massoc 1 lay))) ) ) ) (defun massoc (key alist / nlist) (foreach x alist (if (eq key (car x)) (setq nlist (cons (cdr x) nlist)) ) ) (reverse nlist) ) So for the first layout it would be (TAB 1) ;go to first tab (TAB 4) ;go to fourth tab Edited June 6, 2022 by mhupp Changed code to be dynamic Quote
ILoveMadoka Posted June 6, 2022 Author Posted June 6, 2022 I have to to laugh... If you provide a solution, they want options, if you provide options, they want a simple solution... In my case, I will always want to go to Tab 1 <only> What will that code look like eliminating the option/dynamic option? This works but is it the best way? (defun c:ZAL (/) ;; Zoom extents in All Layouts (excluding Model) ;; Alan J. Thompson (defun TAB (x / laylst tab lay) ;;;; mhupp 2022.06.06 ;;;; https://www.cadtutor.net/forum/topic/75347-zoom-extents-all-layouts-2022/ (setq laylst (massoc 350 (dictsearch (namedobjdict) "acad_layout"))) (foreach tab laylst (setq lay (entget tab)) (if (eq x (cdr (assoc 71 lay))) ;made it dynamic (setvar 'ctab (last (massoc 1 lay))) ) ) ) (defun massoc (key alist / nlist) (foreach x alist (if (eq key (car x)) (setq nlist (cons (cdr x) nlist)) ) ) (reverse nlist) ) (Tab 1) (or *Acad* (setq *Acad* (vlax-get-acad-object))) (or *AcadDoc* (setq *AcadDoc* (vla-get-activedocument *Acad*))) ((lambda (ctab) (foreach layout (layoutlist) (setvar 'ctab layout) (vla-put-mspace *AcadDoc* :vlax-false) (vla-zoomextents *Acad*) ) (setvar 'ctab ctab) ) (getvar 'ctab) ) (princ) ) Thank you! Quote
ILoveMadoka Posted June 6, 2022 Author Posted June 6, 2022 (edited) <Deleted> Edited June 6, 2022 by ILoveMadoka Quote
Steven P Posted June 6, 2022 Posted June 6, 2022 (layoutlist) will list the layout tab names (setvar 'ctab (nth 0 (layoutlist))) will take you to the first layout in that list, you could add this in as the first line? Note that the first layout isn't necessary what you might consider to be the first layout (typically the one shown as the left hand layout tab), but will be the first layout the was created (typicaly Layout1 or whatever it is renamed to be) regardless of where in the tabs list it is shown. Quote
mhupp Posted June 6, 2022 Posted June 6, 2022 (edited) 11 hours ago, Steven P said: Note that the first layout isn't necessary what you might consider to be the first layout (typically the one shown as the left hand layout tab), but will be the first layout the was created (typicaly Layout1 or whatever it is renamed to be) regardless of where in the tabs list it is shown. That's why I left it dynamic 11 hours ago, ILoveMadoka said: This works but is it the best way always a better way. little googling (defun c:ZAL (/) ;; Zoom extents in All Layouts (excluding Model) ;; Alan J. Thompson (vl-load-com) (or *Acad* (setq *Acad* (vlax-get-acad-object))) (or *AcadDoc* (setq *AcadDoc* (vla-get-activedocument *Acad*))) ((lambda (ctab) (foreach layout (layoutlist) (setvar 'ctab layout) (vla-put-mspace *AcadDoc* :vlax-false) (vla-zoomextents *Acad*) ) (setvar 'ctab ctab) ) (getvar 'ctab) ) (vlax-for i (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (if (= (vla-get-taborder i) 1) (setvar 'ctab (vla-get-name i)))) (princ) ) Edited June 7, 2022 by mhupp 1 Quote
BIGAL Posted June 6, 2022 Posted June 6, 2022 This is as name implies goto layout, "Model" is layout 0. Just remove all the choose part. Goto-layout.lsp 1 Quote
Steven P Posted June 7, 2022 Posted June 7, 2022 8 hours ago, BIGAL said: This is as name implies goto layout, "Model" is layout 0. Just remove all the choose part. Goto-layout.lsp 829 B · 4 downloads i think Goot is so much better than goto for a command 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.