Author Topic: New Tab Order with TabMover.lsp  (Read 8245 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
New Tab Order with TabMover.lsp
« on: August 22, 2005, 07:43:46 PM »
This is the "First Draft' if you will of a routine to rearrange the tab order.
The dialog box must be in the ACAD path.
Highlight a tab in the pick list then use the Up/Down buttons to move it.
Continue with other picks until you have the order you want the select the
Finished button.

I only have a few hours into it so there is a lot of cleanup to do yet but
I thought I would get some feed back before I go for round 2.
So if you don't mind alpha testing :) have a go with it.
I did limited testing in ACAD2000 only.


Code updated, see later message.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Crank

  • Water Moccasin
  • Posts: 1503
New Tab Order with TabMover.lsp
« Reply #1 on: August 23, 2005, 05:32:16 AM »
Seems to be OK, because I can't find any bugs. :)

Perhaps it's an idea to move more tabs at once (with CTRL pressed) or to add some buttons for sorting the tabs. Just like you did in PlotTabs.
Vault Professional 2023     +     AEC Collection

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
New Tab Order with TabMover.lsp
« Reply #2 on: August 23, 2005, 01:33:08 PM »
Thanks Crank for the suggestions.

Here is round 2.
Code: [Select]
;;;  [Buttons]
;;;  [First   ] Move the tab to top of list
;;;  [Up      ] Move the tab up one
;;;  [Insert  ] Insert the tab at a new location
;;;  [Down    ] move the tab down one
;;;  [Last    ] Move the tab to bottom of list
;;;  [Alphabet] Sort the list Alphabetically
;;;  [Invert  ] Invert the order
;;;  [Finished] Apply the changes to the tabs
;;;  [Cancel  ] Quit without changes


Insert works like this, select a tab to move. Press the Insert button.
All other tab buttons are dimmed. Select the tab you wish to insert the
tab on top of.


Code: [Select]
;;;       ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;;;       +                  TabMover.lsp                          +
;;;       +            Created by C. Alan Butler                   +
;;;       +               Copyright  2005                          +
;;;       +   by Precision Drafting & Design All Rights Reserved.  +
;;;       +    Contact at ab2draft@TampaBay.rr.com                 +
;;;       ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;;;
;;; FUNCTION
;;; Dialog box to rearrange the tab order
;;;
;;; ARGUMENTS
;;; none
;;;
;;; USAGE
;;; tabmover
;;;
;;; PLATFORMS
;;; 2000+
;;;
;;;
;;; VERSION
;;; 1.01 Aug 23, 2005
;;;
;;;
;;;  [Buttons]
;;;  [First   ] Move the tab to top of list
;;;  [Up      ] Move the tab up one
;;;  [Insert  ] Insert the tab at a new location
;;;  [Down    ] move the tab down one
;;;  [Last    ] Move the tab to bottom of list
;;;  [Alphabet] Sort the list Alphabetically
;;;  [Invert  ] Invert the order
;;;  [Finished] Apply the changes to the tabs
;;;  [Cancel  ] Quit without changes
;;;
;;;
;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
;;;   WARRANTY.  ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
;;;   PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
;;;                                                                    ;
;;;  You are hereby granted permission to use, copy and modify this    ;
;;;  software without charge, provided you do so exclusively for       ;
;;;  your own use or for use by others in your organization in the     ;
;;;  performance of their normal duties, and provided further that     ;
;;;  the above copyright notice appears in all copies and both that    ;
;;;  copyright notice and the limited warranty and restricted rights   ;
;;;  notice below appear in all supporting documentation.              ;


(defun c:tabmover (/ dclfile dcl# action ptr
                   move load_list dialog_data doit)
  ;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
  ;;                      Local Functions                          
  ;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-

  ;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
  ;;                  Move the tab within the list                  
  ;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
  (defun move (ptr newptr layouts / idx tmp tab)
    (cond
      ((= ptr newptr) ; no action
       ) ; cond 1
      ;; move up or down one in list
      ((or (= (1+ ptr) newptr) (= (1+ newptr) ptr))
        (setq idx (length layouts))
        (while (> (setq idx (1- idx)) -1)
          (if (or (= idx ptr) (= idx newptr))
            (setq tmp (cons (nth (min ptr newptr) layouts) tmp)
                  tmp (cons (nth (max ptr newptr) layouts) tmp)
                  idx  (1- idx)
            )
            (setq tmp (cons (nth idx layouts) tmp))
          )
        )
        (setq layouts tmp)
      ) ; cond 2
      (T ; move to newptr location
        (setq idx (length layouts)
              tab (nth ptr layouts))
        (while (> (setq idx (1- idx)) -1)
          (cond
            ((= idx ptr) ; skip the removed tab
             ()
            )
            ((= idx newptr) ; add the moved tab
             (setq tmp (cons (nth idx layouts) tmp)
                   tmp (cons tab tmp))
            )
            ((and (= newptr (length layouts))
                  (= idx (1- (length layouts)))); move to bottom
             (setq tmp (cons tab tmp)
                   tmp (cons (nth idx layouts) tmp))
            )
            (t
             (setq tmp (cons (nth idx layouts) tmp))
            )
          )
        )
        (setq layouts tmp)
      ) ; cond 3
    ); end cond stmt
    layouts
  ) ; end defun

  ;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
  ;;                    Load the layout list                        
  ;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
  (defun load_list (layouts cur_tab / n one)
    (start_list "layouts")
    (foreach one layouts
      (add_list one)
    )
    (end_list)
    (if (setq n (vl-position cur_tab layouts))
      (set_tile "layouts" (itoa n))
      (set_tile "layouts" "0")
    )
  ) ; end defun


  ;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
  ;;                       Load dialog actions                      
  ;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
  (defun dialog_data (ptr layouts ins_on)
    (load_list layouts (nth ptr layouts))
    (action_tile "UP" "(Setq Action 1)(done_dialog 5)")
    (action_tile "DN" "(Setq Action 2)(done_dialog 5)")
    (action_tile "top" "(Setq Action 3)(done_dialog 5)")
    (action_tile "bot" "(Setq Action 4)(done_dialog 5)")
    (action_tile "ins" "(Setq Action 5)(done_dialog 5)")
    (action_tile "srt" "(Setq Action 7)(done_dialog 5)")
    (action_tile "inv" "(Setq Action 8)(done_dialog 5)")
    (action_tile "ok" "(Setq Action -1)(done_dialog 5)")
    (action_tile "cancel" "(Setq Action 0)(done_dialog 1)")
    (if ins_on
      (progn
        (action_tile "layouts" "(setq ptr (ATOI $value) Action 6)(done_dialog 5)")
        (mode_tile "UP" 1)  ;disabled
        (mode_tile "DN" 1)  ;disabled
        (mode_tile "top" 1) ;disabled
        (mode_tile "bot" 1) ;disabled
        (mode_tile "srt" 1) ;disabled
        (mode_tile "inv" 1) ;disabled
        (set_tile "txt1" "*** Now select the tab where the insert will be inserted ***")
        (set_tile "txt2" "*** Or press the Insert button to cancel this insert   ***")
      )
      (progn
        (action_tile "layouts" "(setq ptr (ATOI $value))")
        (mode_tile "UP" 0)  ;enabled
        (mode_tile "DN" 0)  ;enabled
        (mode_tile "top" 0) ;enabled
        (mode_tile "bot" 0) ;enabled
        (mode_tile "srt" 0) ;enabled
        (mode_tile "inv" 0) ;enabled
        (set_tile "txt1" "INSERT: Select a tab to move, press insert button, select")
        (set_tile "txt2" "where to insert in list or Insert again to cancel")
      )
     )
  ) ; end defun


  ;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
  ;;                     Run the Dialog                            
  ;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
  (defun doit (dcl_id / x y layouts vlayouts ptr action doc one tmp
               cnt newptr ins_on)
    ;; get tab names, sort in tab order & remove model
    (vlax-map-collection
      (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))
      '(lambda (x) (setq vlayouts (cons x vlayouts)))
    )
    ;;  sort in tab order & remove model
    (setq vlayouts (cdr (vl-sort vlayouts
                            '(lambda (x y)
                               (< (vla-get-taborder x) (vla-get-taborder y))
                             )
                   ))
    )
    ;;  make list of names into strings  remove Model space
    (setq layouts (mapcar '(lambda (x) (vla-get-name x)) vlayouts))
   
    (setq ptr 0) ; start at the top of the list
    (dialog_data ptr layouts ins_on) ; actions

    (setq do_dialog t) ; flag loop to start

    ;;  repeat dialog until user exits
    (while do_dialog
      ;;  Start Dialog Box
      (if (= (setq tmp (start_dialog)) 5) ; temp exit of dialog
        (progn
          (cond
            ((= action 1) ; move_up
             (setq newptr (max (1- ptr) 0)
                   layouts (move ptr newptr layouts)
                   ptr newptr)
            ) ; end cond 1
            ((= action 2) ; move down
             (setq newptr (min (1+ ptr) (1- (length layouts)))
                   layouts (move ptr newptr layouts)
                   ptr newptr)
            ) ; end cond 2
            ((= action 3) ; move to top
             (setq newptr 0
                   layouts (move ptr newptr layouts)
                   ptr 0)
            ) ; end cond 3
            ((= action 4) ; move to bottom
             (setq newptr (length layouts)
                   layouts (move ptr newptr layouts)
                   ptr (1- (length layouts)))
            ) ; end cond 4
            ((= action 5) ; insert toggle
             ;;  after button is pressed get the next pointer location
             ;;  if button is pressed again before selection cancel insert
             (setq ins_on (not ins_on)
                   newptr ptr) ; save pointer
            ) ; end cond 5
            ((= action 6) ; insert
             ;;  ptr points to the new location, newptr points to the old location
             (setq layouts (move newptr ptr layouts)
                   ins_on nil)
            ) ; end cond 6
            ((= action 7) ; sort alpha
             (setq layouts (vl-sort layouts '<))
            ) ; end cond 7
            ((= action 8) ; invert list
             (setq layouts (reverse layouts))
            ) ; end cond 8
            ((= action -1) ; rearange the tabs
             (setq cnt 1
                   doc (vla-get-activedocument (vlax-get-acad-object))
             )
             (foreach one layouts
               (vla-put-taborder (vla-item (vla-get-layouts doc) one) cnt)
               (setq cnt (1+ cnt))
             )
            ) ; end cond 9
          ) ; end cond stmt
          (if (> action 0)
            (progn
              ;;  restart the dialog box
              (new_dialog "tabmover" dcl_id)
              (dialog_data ptr layouts ins_on)
            ) ; progn
            ;;  ELSE user wants to quit
            (setq do_dialog nil)
          ) ; endif

        ) ; end progn
        ;;  ELSE user wants to quit
        (setq do_dialog nil)
      )
    ) ; endwhile
    (unload_dialog dcl_id)

  ) ; end defun


  ;;================================================================
  ;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
  ;;================================================================
  ;;                    Start of Routine                            
  ;;================================================================
  ;; -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=- -=<*>=-
  ;;================================================================
  (vl-load-com)

  (setq dclfile "tabmover.dcl")
  (cond
    ((< (setq dcl# (load_dialog dclfile)) 0) ; Error
     (prompt (strcat "\nCannot load " dclfile "."))
    )
    ((not (new_dialog "tabmover" dcl#)) ; Error
     (prompt (strcat "\nProblem with " dclfile "."))
    )
    (t ; No DCL problems: fire it up
     (doit dcl#)
    ) ; end cond T
  ) ; end cond
  (princ)
) ; end defun main

(prompt "\n***---  Tab Mover Loaded, type Tabmover to run  ---***")
(princ)



Save this as TabMover.dcl in the ACAD search path.
Code: [Select]
dcl_settings : default_dcl_settings { audit_level = 3; }

tabmover : dialog {
    label = "   Tab Mover by CAB v1.01";
    : boxed_row {
        label = "< Tabs >";
        : list_box {
            key = "layouts";
            width = 30;
            height = 20;
        }
        : column {
            : button {
                label = "First";
                key = "top";
                mnemonic = "F";
            }
            : button {
                label = "Up";
                key = "UP";
                mnemonic = "U";
            }
            : button {
                label = "Insert";
                key = "ins";
                mnemonic = "I";
            }
            : button {
                label = "Down";
                key = "DN";
                mnemonic = "D";
            }
            : button {
                label = "Last";
                key = "bot";
                mnemonic = "L";
            }
            : spacer {
                height = 2;
            }
            : button {
                label = "Alphabetical";
                key = "srt";
                mnemonic = "A";
            }
            : button {
                label = "inVert";
                key = "inv";
                mnemonic = "V";
            }
        }
    }
    : text { key = "txt1" ;
             width = 65 ;
             alignment = centered ; }
    : text { key = "txt2" ;
             width = 65 ;
             alignment = centered ; }
   : row {
    : button {
        label = "Finished";
        key = "ok";
        mnemonic = "F";
        // fixed_width = true ;
    }
    : cancel_button {}
    }
}
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

whdjr

  • Guest
New Tab Order with TabMover.lsp
« Reply #3 on: August 23, 2005, 02:32:36 PM »
Very nice routine CAB.  I like everything you have included.  I have 2 suggestions for you to think about:

1.  Let the listbox allow multiple selection so a user can move a group of tabs together.

2.  Allow the user to sort either alpha or numericly first.

Good job!

whdjr

  • Guest
New Tab Order with TabMover.lsp
« Reply #4 on: August 23, 2005, 02:33:25 PM »
3.  Maybe make the listbox a little bit wider.

 :)

Crank

  • Water Moccasin
  • Posts: 1503
New Tab Order with TabMover.lsp
« Reply #5 on: August 23, 2005, 02:41:52 PM »
Less is more...
I don't see any use of the invert button.
The insert button works good, but is to difficult to understand without explaning.

@ Will:
1 That's what I mean with the CTRL-button.
2 I agree
3 maybe something like this:
Code: [Select]

dcl_settings : default_dcl_settings { audit_level = 3; }

tabmover : dialog {
    label = "   Tab Mover by CAB v1.01";
    : boxed_row {
        label = "< Tabs >";
        : list_box {
            key = "layouts";
            width = 25;
            height = 20;
        }
        : column {
            : button {
                label = "First";
                key = "top";
                mnemonic = "F";
            }
            : button {
                label = "Up";
                key = "Up";
                mnemonic = "U";
            }
            : button {
                label = "Down";
                key = "DN";
                mnemonic = "D";
            }
            : button {
                label = "Last";
                key = "bot";
                mnemonic = "L";
            }
            : spacer {
                height = 2;
            }
            : button {
                label = "Alphabetical";
                key = "srt";
                mnemonic = "A";
            }
            : button {
                label = "Numeric";
                key = "srt_num";
                mnemonic = "N";
            }
        }
    }
    : row {
    }
    : button {
        label = "Finished";
        key = "ok";
        mnemonic = "F";
    }
    : cancel_button {}
}
Vault Professional 2023     +     AEC Collection

whdjr

  • Guest
New Tab Order with TabMover.lsp
« Reply #6 on: August 23, 2005, 02:44:58 PM »
Sorry for stepping on your comments Crank.  I didn't even see your post. :shock:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
New Tab Order with TabMover.lsp
« Reply #7 on: August 23, 2005, 03:02:37 PM »
Will, thanks for the reply.
You must have long tab names. I keep the short myself.
Or were you talking about the asthectics of the box?

Group selections are easy to impliment on the pick lisst but add some complecited
in the routine. I'm sure you know all about that.
I usually have 6 to 10 tabs in a drawing but reading post here I see some people
have large number of tabs. So for them I guess a multi select may be useful.

You can sort at any time and keep munipulating the list as you like until you
are satisfied with the list.
Do you think numerical sort is needed?

Crank, I like it..  nice touch with the mnemonics.
I added the image next to the old one above to compare.
Do you think the numeric sort is needed?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

whdjr

  • Guest
New Tab Order with TabMover.lsp
« Reply #8 on: August 23, 2005, 03:41:49 PM »
Most of tab names are the sheet name followed by a hypen with a short description.  We may have upwards of 50 so it helps on navigation.  Also the box just looked a little skinny too.

I wouldn't use the numerical sort (that I know of) here but others might find it usefull.  I just thought the functionality would be good for others.

Good job on the tool.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
New Tab Order with TabMover.lsp
« Reply #9 on: August 23, 2005, 04:37:54 PM »
Thanks Will,
I updated the screen shot again.
Fattened the box a little more, traded the numeric sort for invert.
Not that anyone will need the invert, I may loose that too.
I'll post the updated code in a few.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
New Tab Order with TabMover.lsp
« Reply #10 on: August 23, 2005, 04:47:09 PM »
Ok, there is the new code.
I have not addresses the Milti-selection option yet.
I need to do some work today, so it will have to wait. :(
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
New Tab Order with TabMover.lsp
« Reply #11 on: August 23, 2005, 05:39:22 PM »
Changed the code once more, added a dynamic text message to explain the INSERT
function, it changes when you start the command.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
New Tab Order with TabMover.lsp
« Reply #12 on: August 24, 2005, 01:26:52 PM »
Here is the Multi-Select Version.
TabMover.zip

Code: [Select]
;;;   The pick box allows Multi-seletions. This is accomplished with the
;;;   Shift and Ctrl keys. To select sententially just left click & drag
;;;   the pointer over the selections or click the one end of the list to
;;;   be selected then Shift Click the other end. To select non sequential
;;;   items use the Ctrl Key and Ctrl left click the items to be added to
;;;   the selection.  Pick the Insert Button to cash this list of selected
;;;   items. Then pick in the list to identify the insert point. That item
;;;   will be pushed down &  the list inserted.


I tested but you know how that goes. :)
Please report any anomalies, better known as bugs. 8)

Thanks
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

whdjr

  • Guest
New Tab Order with TabMover.lsp
« Reply #13 on: August 24, 2005, 05:30:57 PM »
CAB,

I like the new multi-select version.  My first thought was 'This suck!' when I selected a group of tabs and clicked down and then my selectionset was gone.  But after looking at and reading about the insert option I think I like it.

It's pretty nice.

Have you tried it on any other version yet?  I'll try on 2006 and see if it works.

whdjr

  • Guest
New Tab Order with TabMover.lsp
« Reply #14 on: August 24, 2005, 05:35:56 PM »
Okay CAB,  I tried it in 2006 and it works great.

I tried some of the options with multi-select and they all work great.  All the buttons work with just your selection --- pretty KOOL stuff :dood:  :dood: