TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MSTG007 on September 24, 2020, 08:44:17 AM

Title: Activate the first Layout Tab
Post by: MSTG007 on September 24, 2020, 08:44:17 AM
I know this is a dumb one to ask for. I am having a hard time figuring out how to activate the first layout tab in a current dwg. I have a routine that will make X copies of the current layout tab, usually it will end at the last layout tab. I was wondering how to get it back to the first layout tab.

Thanks guys for pointing me in the right direction.
Title: Re: Activate the first Layout Tab
Post by: HOSNEYALAA on September 24, 2020, 08:55:21 AM
Code: [Select]


(COMMAND "Layout" "COPY" "Layout1" "1")

(COMMAND "Layout" "SET" "Layout1")

Title: Re: Activate the first Layout Tab
Post by: Tharwat on September 24, 2020, 09:00:24 AM
Code - Auto/Visual Lisp: [Select]
  1. ;; assign the name of the current layout before running your codes.
  2. (setq cur (getvar 'CTAB))
  3. ;; your codes that doing some stuff here .....
  4. ;; Reset or back to original layout.
  5. (setvar 'CTAB cur)
  6.  
Title: Re: Activate the first Layout Tab
Post by: MSTG007 on September 24, 2020, 10:01:07 AM
Would this code be generic enough for any named layout tab or does it have to be specific to use?
Title: Re: Activate the first Layout Tab
Post by: Tharwat on September 24, 2020, 10:35:53 AM
Regardless of your active layout name you are on.
Title: Re: Activate the first Layout Tab
Post by: MSTG007 on September 24, 2020, 10:42:19 AM
Excellent! Thank you for the clarification on it! I really appreciate it!
Title: Re: Activate the first Layout Tab
Post by: Tharwat on September 24, 2020, 10:44:15 AM
Excellent! Thank you for the clarification on it! I really appreciate it!
You're welcome anytime.
Title: Re: Activate the first Layout Tab
Post by: alanjt on September 24, 2020, 11:18:48 AM
Keep in mind, this works as long as you don't change the name of the layout tab while the program is running.
Title: Re: Activate the first Layout Tab
Post by: MSTG007 on September 24, 2020, 11:59:55 AM
Just want to clarify, if layout1 is copied 8 times, and then renamed to layout1, layout2, etc. it will still go back to layout1.
Title: Re: Activate the first Layout Tab
Post by: Tharwat on September 24, 2020, 12:06:36 PM
Just want to clarify, if layout1 is copied 8 times, and then renamed to layout1, layout2, etc. it will still go back to layout1.
Try to do it yourself to learn from what you come up with your codes, and such practices you would be remember for a long time so this is one of the best ways to be good at coding.
Title: Re: Activate the first Layout Tab
Post by: MSTG007 on September 24, 2020, 12:09:17 PM
Not a problem. I did not want to get to far ahead of myself! lol Thank you for the advice.
Title: Re: Activate the first Layout Tab
Post by: BIGAL on September 28, 2020, 11:14:59 PM
I wrote this as there is no "goto" a layout, like Word has goto page x.

It has the answer to your problem.

Code: [Select]
; GOTO layout just like other goto a page
; By Alan H 2013
; menu command [GOTO]^c^C^p(load "goto")
; enter a big number like 99 to jump to last if 100+ layouts then 123 etc
; Model space is 0 zero GOTO 0

(defun C:goto ( / x alllayouts laynum num)

(setq num (getint  "Enter layout number" ))
(setq alllayouts (vla-get-Layouts (vla-get-activedocument (vlax-get-acad-object))))
(SETQ LAYNUM 0)
(vlax-for x alllayouts
(Setq laynum (+ 1 laynum))
) ;total number of layouts
(if (> num laynum)
(setq num (- laynum 1))
)
(vlax-for lay alllayouts
(if (= num (vla-get-taborder lay))
(setvar "ctab" (vla-get-name lay))
)
)
)

; I often type it wrong so added this one also
(defun C:goot ()
(c:goto)
) ; defun
Title: Re: Activate the first Layout Tab
Post by: d2010 on September 29, 2020, 07:01:10 AM
You get maxLayouts with thiscode
Code: [Select]
(setq laynum (length (layoutlist)))   :wideeyed2:
Code: [Select]
You cannot run the "pp_bigalayout_jspin15.lsp"
without "Password PinAcces=6548"
Not a problem. I did not want to get to far ahead of myself! lol Thank you for the advice.