Author Topic: Activate the first Layout Tab  (Read 1944 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Activate the first Layout Tab
« 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.
Civil3D 2020

HOSNEYALAA

  • Newt
  • Posts: 103
Re: Activate the first Layout Tab
« Reply #1 on: September 24, 2020, 08:55:21 AM »
Code: [Select]


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

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


Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Activate the first Layout Tab
« Reply #2 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.  

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Activate the first Layout Tab
« Reply #3 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?
Civil3D 2020

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Activate the first Layout Tab
« Reply #4 on: September 24, 2020, 10:35:53 AM »
Regardless of your active layout name you are on.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Activate the first Layout Tab
« Reply #5 on: September 24, 2020, 10:42:19 AM »
Excellent! Thank you for the clarification on it! I really appreciate it!
Civil3D 2020

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Activate the first Layout Tab
« Reply #6 on: September 24, 2020, 10:44:15 AM »
Excellent! Thank you for the clarification on it! I really appreciate it!
You're welcome anytime.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Activate the first Layout Tab
« Reply #7 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.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Activate the first Layout Tab
« Reply #8 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.
Civil3D 2020

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Activate the first Layout Tab
« Reply #9 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.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Activate the first Layout Tab
« Reply #10 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.
Civil3D 2020

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: Activate the first Layout Tab
« Reply #11 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
A man who never made a mistake never made anything

d2010

  • Bull Frog
  • Posts: 326
Re: Activate the first Layout Tab
« Reply #12 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.
« Last Edit: September 29, 2020, 07:17:55 AM by d2010 »