Author Topic: Move Active Layout Tab to End  (Read 2862 times)

0 Members and 1 Guest are viewing this topic.

cmwade77

  • Swamp Rat
  • Posts: 1443
Move Active Layout Tab to End
« on: December 15, 2014, 07:42:38 PM »
I have found a lot of very complicated code for moving layout tabs, but I can't seem to find anything simple that shows me how to move the currently active layout tab to the end of the layout tabs. Can anyone help me out here? At least point me in the right direction with some simple code examples?

ymg

  • Guest
Re: Move Active Layout Tab to End
« Reply #1 on: December 15, 2014, 09:47:15 PM »
cmwade77,

How about copy current layout, followed by a delete
then a set and finally a rename.

All this with the layout command,

ymg

Rod

  • Newt
  • Posts: 185
Re: Move Active Layout Tab to End
« Reply #2 on: December 15, 2014, 10:54:01 PM »
This seems to work. You will need to add in error checking to make sure the user is not in model space
Code - Auto/Visual Lisp: [Select]
  1. (defun C:putmelast ()
  2.   (setq acadObj (vlax-get-acad-object))
  3.   (setq doc (vla-get-ActiveDocument acadObj))
  4.   (setq layouts (vla-get-Layouts doc))
  5.   (setq ActiveLayout (vla-item layouts (getvar "CTAB")))
  6.   (vla-put-taborder activelayout (1- (vla-get-count layouts)))
  7. )
"All models are wrong, some models are useful" - George Box

ymg

  • Guest
Re: Move Active Layout Tab to End
« Reply #3 on: December 16, 2014, 12:36:05 AM »
I came up with this, but Ausrod solution is cleaner.

Code - Auto/Visual Lisp: [Select]
  1. (defun movctab ( )
  2.    
  3.    (setq    ctab (getvar "ctab")
  4.             layl (append (vl-remove ctab (layoutlist)) (list ctab))
  5.    )
  6.    (vlax-for tab layouts
  7.      (if (/= (setq name (vla-get-name tab)) "Model")
  8.         (vla-put-taborder tab (+ (vl-position (vla-get-name tab) layl) 1))
  9.      )
  10.    )  
  11. )
  12.  
  13.  

Ausrod's solution is essentially two lines:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:putmelast ( / layouts)  
  2.    (vla-put-taborder (vla-item layouts (getvar "CTAB")) (1- (vla-get-count layouts)))
  3. )
  4.  
« Last Edit: December 16, 2014, 01:04:18 AM by ymg »

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Move Active Layout Tab to End
« Reply #4 on: December 16, 2014, 12:36:33 AM »
Try this .

Code - Auto/Visual Lisp: [Select]
  1. (defun c:GoLast (/ l)
  2.   ;;    Tharwat 16.Dec.2014     ;;
  3.   (if (and (< 2
  4.               (vla-get-count
  5.                 (setq l (vla-get-Layouts
  6.                           (vla-get-ActiveDocument (vlax-get-acad-object))
  7.                         )
  8.                 )
  9.               )
  10.            )
  11.            (eq 0 (getvar 'TILEMODE))
  12.       )
  13.       (vla-item l (getvar 'CTAB))
  14.       (1- (vla-get-count l))
  15.     )
  16.     (princ "\n ** Commnad is not allowed in Model Space **")
  17.   )
  18.   (princ)
  19.  

Patrick_35

  • Guest
Re: Move Active Layout Tab to End
« Reply #5 on: December 16, 2014, 02:22:57 AM »
Hi

And my example
Code: [Select]
(defun c:test(/ doc)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-startundomark doc)
  (vl-catch-all-apply 'vla-put-taborder (list (vla-get-activelayout doc) (1- (vla-get-count (vla-get-layouts doc)))))
  (vla-endundomark doc)
  (princ)
)

@+
« Last Edit: December 16, 2014, 03:16:42 AM by Patrick_35 »

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Move Active Layout Tab to End
« Reply #6 on: December 16, 2014, 02:26:19 AM »
@ Patrick
Try your codes while you are in Model space . :wink:

Patrick_35

  • Guest
Re: Move Active Layout Tab to End
« Reply #7 on: December 16, 2014, 03:16:18 AM »
@ Patrick
Try your codes while you are in Model space . :wink:
Oh yes, but as we asked for the active layout
The code is modified according to your point