gohanrice Posted May 29, 2009 Posted May 29, 2009 I know that Ctrl+Page Up and Ctrl+Page Down cycles through the Layout Tabs, but is there a way to change the keystroke to something else? I've always got one hand on the mouse and one on the keyboard, so I'm hoping to change one of the two to something like Shift-Tab (as Ctrl-Tab cycles through open Application Windows and Alt-Tab cycles through Windows within a given Application). Quote
Commandobill Posted May 29, 2009 Posted May 29, 2009 You can use this code (not written by me) then set it up in your cui to have 'nextlayout' and 'previouslayout' as keyboard shortcut commands.... ;; Created by: Lee Ambrosius ;; Date Written: 12/11/03 ;; Includes four commands which can be redefined. ;; NextLayout - Navigates to the right and will wrap around ;; to the left side once the end is reached ;; PreviousLayout - Navigates to the left and will wrap around ;; to the right side once the end is reached ;; FirstLayout - Navigates to the left most tab ;; LstLayout - Navigates to the right most tab ;; Gets a listing of all Layouts in the drawing (defun Get-Layout-List( / acadObj acDoc acDocLayouts layoutCount loopCount layoutListLocal layoutListSorted layoutName layoutPosition loopCountSorted) (vl-load-com) (setq acadObj (vlax-get-acad-object)) (setq acDoc (vlax-get-property acadObj 'ActiveDocument)) (setq acDocLayouts (vlax-get-property acDoc 'Layouts)) (setq layoutCount (vlax-get-property acDocLayouts 'Count) loopCount 0 layoutListLocal (list) layoutListSorted (list) ) (while (> layoutCount loopCount) (setq layoutName (vlax-get-property (vlax-invoke-method acDocLayouts 'Item loopCount) 'Name)) (setq layoutPosition (vlax-get-property (vlax-invoke-method acDocLayouts 'Item loopCount) 'TabOrder)) (setq layoutListLocal (append layoutListLocal (list (list layoutPosition layoutName)))) (setq loopCount (1+ loopCount)) ) ;; Resort listing by TabOrder (setq layoutCountSorted 0) (while (> (length layoutListLocal) (length layoutListSorted)) (setq loopCountSorted 0) (foreach layoutLocation layoutListLocal (progn (if (and (= (car layoutLocation) (length layoutListSorted)) (= (car layoutLocation) layoutCountSorted)) (progn (setq layoutListSorted (append layoutListSorted (cdr (nth loopCountSorted layoutListLocal)))) (setq layoutCountSorted (1+ layoutCountSorted)) ) ) (setq loopCountSorted (1+ loopCountSorted)) ) ) ) layoutListSorted ) (defun c:nextlayout ( / layout-mem-list layout-list layoutLocation) (setq layoutLocation 0) (setq layout-list (get-layout-list)) (setq layout-mem-list (member (getvar "CTAB") layout-list)) (if layout-mem-list (progn (setq layoutLocation (- (length layout-list) (length layout-mem-list))) ) (setq layoutLocation (1+ layoutLocation)) ) (if (>= (1+ layoutLocation) (length layout-list)) (setvar "CTAB" (nth 0 layout-list)) (setvar "CTAB" (nth (1+ layoutLocation) layout-list)) ) ) (defun c:previouslayout ( / layout-mem-list layout-list layoutLocation) (setq layoutLocation 0) (setq layout-list (get-layout-list)) (setq layout-mem-list (member (getvar "CTAB") layout-list)) (if layout-mem-list (progn (setq layoutLocation (- (length layout-list) (length layout-mem-list))) ) (setq layoutLocation (1- layoutLocation)) ) (if (= layoutLocation 0) (setvar "CTAB" (nth (1- (length layout-list)) layout-list)) (setvar "CTAB" (nth (1- layoutLocation) layout-list)) ) ) (defun c:FirstLayout ( / layout-list layoutLocation) (setvar "CTAB" (nth 0 (get-layout-list))) ) (defun c:LastLayout ( / layout-list) (setq layout-list (get-layout-list)) (setvar "CTAB" (nth (- (length layout-list) 1) layout-list)) ) (princ) 1 Quote
Ashishs Posted August 6, 2009 Posted August 6, 2009 ;; ;;FirstLayout - Navigates to the left most tab (princ) Command "FirstLayout" doesn't really take to first layout. It takes you to model space instead. Is it possible to fix this? Tnx for help in advance. Quote
Lee Mac Posted August 6, 2009 Posted August 6, 2009 I think it could be shortened somewhat... [i][color=#990099];; Layout Switcher, by Lee McDonnell ~ 06.08.2009[/color][/i] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] lays [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] lst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] lay [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Layouts[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] lst [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] lay lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]vla-get-Name[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-sort[/color][/b] lst [b][color=RED]([/color][/b][b][color=BLUE]function[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b]a b[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]<[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-TabOrder[/color][/b] a[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-TabOrder[/color][/b] b[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:nlay [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] pos lst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pos [b][color=RED]([/color][/b][b][color=BLUE]1+[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-position[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]getvar[/color][/b] [b][color=#ff00ff]"CTAB"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] lst [b][color=RED]([/color][/b]lays[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setvar[/color][/b] [b][color=#ff00ff]"CTAB"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]nth[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cond[/color][/b] [b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]length[/color][/b] lst[b][color=RED])[/color][/b] pos[b][color=RED])[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]pos[b][color=RED])[/color][/b][b][color=RED])[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:play [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] pos lst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pos [b][color=RED]([/color][/b][b][color=BLUE]1-[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-position[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]getvar[/color][/b] [b][color=#ff00ff]"CTAB"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] lst [b][color=RED]([/color][/b]lays[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setvar[/color][/b] [b][color=#ff00ff]"CTAB"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]nth[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cond[/color][/b] [b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=BLUE]minusp[/color][/b] pos[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]1-[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]length[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]pos[b][color=RED])[/color][/b][b][color=RED])[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:flay [b][color=RED]([/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setvar[/color][/b] [b][color=#ff00ff]"CTAB"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]nth[/color][/b] [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b]lays[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:llay [b][color=RED]([/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setvar[/color][/b] [b][color=#ff00ff]"CTAB"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]last[/color][/b] [b][color=RED]([/color][/b]lays[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] Quote
2001jonathon Posted August 6, 2009 Posted August 6, 2009 I use at work think one. q will bring you one tab rto the right and qq will bring you one tab to the left. the only thing you cant do is, if you are in model space, you cant use qq to go to the last tab in the series. I hope this helps. (defun c:q (/ ActDoc DocNumb LoCol TabList) (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object))) (setq LoCol (vla-get-Layouts ActDoc)) (vlax-for i LoCol (setq TabList (cons (cons (vla-get-Name i) (vla-get-TabOrder i)) TabList ) ) ) (setq TabList (vl-sort TabList '(lambda (a b) (< (cdr a) (cdr b))))) (setq TabList (append TabList (list (car TabList)))) (setvar "ctab" (car (nth (1+ (vl-position (assoc (getvar "ctab") TabList) TabList ) ) TabList ) ) ) ) (defun c:qq (/ ActDoc DocNumb LoCol TabList) (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object))) (setq LoCol (vla-get-Layouts ActDoc)) (vlax-for i LoCol (setq TabList (cons (cons (vla-get-Name i) (vla-get-TabOrder i)) TabList ) ) ) (setq TabList (vl-sort TabList '(lambda (a b) (< (cdr a) (cdr b))))) (setq TabList (append TabList (list (car TabList)))) (setvar "ctab" (car (nth (1- (vl-position (assoc (getvar "ctab") TabList) TabList ) ) TabList ) ) ) ) Quote
Ashishs Posted August 6, 2009 Posted August 6, 2009 I think it could be shortened somewhat... Great Lee, Thanks for the code once again. Quote
Lee Mac Posted August 6, 2009 Posted August 6, 2009 Great Lee, Thanks for the code once again. No probs dude Quote
jamesfear Posted November 11, 2010 Posted November 11, 2010 Anyone know how to do a LT friendly version haha? Quote
2001jonathon Posted November 11, 2010 Posted November 11, 2010 Here try this and it the lisp should work for you. http://www.cadtutor.net/forum/showthread.php?19027-how-to-load-lisp-program Quote
2001jonathon Posted November 11, 2010 Posted November 11, 2010 I don't know LT, but it should still work. Quote
Lee Mac Posted November 11, 2010 Posted November 11, 2010 LT cannot run LISP without the use of an extender. Quote
alanjt Posted November 11, 2010 Posted November 11, 2010 I suppose if you can figure out the actual command that coincides with Ctrl+Page Up/Down, then you could macro it in your PGP. 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.