Jump to content

TabSort.lsp


Lee Mac

Please Rate this Program:  

24 members have voted

  1. 1. Please Rate this Program:

    • * * * * * (Best)
    • * * * *
    • * * *
    • * *
      0
    • * (Worst)
      0


Recommended Posts

This is a program I posted over at theSwamp.org, but I thought I'd share it with you guys here too.

 

Just a project I was working on recently, written for a bit of fun.

 

TabSort.lsp

Version 2.2

 

Program Controls:

 

Top: Move selected Tabs to the top of the list.

 

Up: Move selected Tabs up one notch in the list.

 

Down: Move selected Tabs down one notch in the list.

 

Bottom: Move selected Tabs to the bottom of the list.

 

Sort.Button.png

Sort: Opens the Sort Dialog:

 

Sort.png

 

Alphabetical: Sort Tabs alphabetically:

 

Hence ~

("A23" "C22" "B3" "E7")

Becomes ~

("A23" "B3" "C22" "E7")

Numerical: Sort Tabs numerically:

 

Hence ~

("A23" "C22" "B3" "E7")

Becomes ~

("B3" "E7" "C22" "A23")

Architectural: Use an Architectural Sorting Method:

 

Hence ~

("A-1A" "B-3" "A-10C" "B-1.2" "B-1")

Becomes ~

("A-1A" "A-10C" "B-1" "B-1.2" "B-3")

ReverseButton.png

Reverse: Reverse the Tab order.

 

PrefSuffButton.png

Pref/Suff: Opens the Prefix/Suffix Dialog to allow the user to add a Prefix and/or Suffix to selected/all Tabs.

 

PrefSuffd.png

 

AddButton.png

Add: Add a new layout Tab.

 

DeleteButton.png

Delete: Deletes selected Tabs.

 

CopyButton.png

Copy: Copies the selected Tabs.

 

CurrentButton.png

Current: Makes the selected Tab the Current Tab.

 

Find.png

Find: Allows the user to perform a Find & Replace:

 

F%26R.png

 

Done: Finished sorting Tabs, will implement sorting.

 

Reset: Will reset Tab names and Tab order ~ will not reset deleted/added Tabs.

 

 

Screenshot:

 

TabSort15.png

 

 

Enjoy!

 

Lee

 

 

 

Full Description here.

TabSortV2-2.lsp

Edited by Lee Mac
  • Thanks 1
Link to comment
Share on other sites

Lee, this program is awesome. It has now instantly been incorporated into our ACADDOC.LSP file and already I'm working on an icon for our Tool Palettes. Thank you much for this very nice addition, my friend. Helps out a lot for us.

 

8)

Link to comment
Share on other sites

Lee, this program is awesome. It has now instantly been incorporated into our ACADDOC.LSP file and already I'm working on an icon for our Tool Palettes. Thank you much for this very nice addition, my friend. Helps out a lot for us.

 

8)

 

Thanks Styk - glad you like it :) Its always great to know that a program is going to be useful for someone 8)

 

What else do you plan to add to it?

 

Well, I had a few other ideas, such as the option of an increment in the Prefix/Suffix Dialog, but I didn't want to "over-do" it, and clutter the dialog too much...

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 year later...

Hello,

 

Regarding the lisp routine "Tabsort v1.9" is there any way to re-number the layouts automaticaly?

i have the layouts name something like (1) (2) (3) ... and i want to change in (73) (74) (75)...

Of course the number of layouts in bigger (hundreds).

Anyway the lisp is great and is very usefull.

Thank you.

Link to comment
Share on other sites

Hi bogdancic26,

 

Would you be able to accomplish your task using the existing Pref/Suffix and/or Find/Replace functionalities?

 

Also, bear in mind that the latest version of the program is 2.1

 

Regards,

 

Lee

Link to comment
Share on other sites

Try something like this:

 

(defun c:LayoutNum ( / *error* _StartUndo _EndUndo doc pref suff l ) (vl-load-com)
 ;; © Lee Mac 2010

 (defun *error* ( msg )
   (if doc (_EndUndo doc))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ)
 )

 (defun _StartUndo ( doc ) (_EndUndo doc)
   (vla-StartUndoMark doc)
 )

 (defun _EndUndo ( doc )
   (if (= 8 (logand 8 (getvar 'UNDOCTL)))
     (vla-EndUndoMark doc)
   )
 )

 (setq doc  (vla-get-ActiveDocument (vlax-get-acad-object)))

 (setq *num
   (1-
     (cond
       (
         (getint
           (strcat "\nSpecify Starting Number <"
             (itoa
               (setq *num
                 (1+
                   (cond ( *num ) ( 0 ))
                 )
               )
             )
             "> : "
           )
         )
       )
       ( *num )
     )
   )
 )

 (setq pref (getstring t "\nSpecify Prefix <None>: ")
       suff (getstring t "\nSpecify Suffix <None>: ")
 )

 (_StartUndo doc)

 (mapcar
   (function
     (lambda ( layout )
       (vla-put-name layout (strcat pref (itoa (setq *num (1+ *num))) suff))
     )
   )
   (vl-sort
     (vlax-for layout (vla-get-Layouts doc)
       (if (not (eq "MODEL" (strcase (vla-get-Name layout))))
         (setq l (cons layout l))
       )
       l
     )
     (function
       (lambda ( a b ) (< (vla-get-TabOrder a) (vla-get-TabOrder b)))
     )
   )
 )

 (_EndUndo doc)  
 (princ)
)

Link to comment
Share on other sites

Something similar I did a while back...

 

(defun c:TabInc (/ pre suf num)
 ;; Tab Increment
 ;; Rename layout tabs with number, based on location
 ;; Prefix and Suffix optional
 ;; Alan J. Thompson, 02.25.09 / 04.08.10 / 12.16.10
 (setq pre (getstring T "\nSpecify prefix <None>: "))
 (setq suf (getstring T "\nSpecify suffix <None>: "))
 (initget 6)
 (setq num (1- (cond ((getint "\nSpecify starting number <1>: "))
                     (1)
               )
           )
 )
 (vlax-for x (vla-get-layouts
               (cond (*AcadDoc*)
                     ((setq *AcadDoc* (vla-get-activedocument
                                        (vlax-get-acad-object)
                                      )
                      )
                     )
               )
             )
   (vl-catch-all-apply
     (function vla-put-name)
     (list x (strcat (rtos (getvar 'date) 2 16) "-" (itoa (vla-get-taborder x))))
   )
 )
 (vlax-for x (vla-get-layouts *AcadDoc*)
   (vl-catch-all-apply
     (function vla-put-name)
     (list x (strcat pre (itoa (+ num (vla-get-taborder x))) suf))
   )
 )
 (princ)
)

Link to comment
Share on other sites

Thank you Lee and Alanjt,

 

Both routine is working for what i want.

You did a great work.

 

Have a great day!

Edited by bogdancic26
Link to comment
Share on other sites

  • 4 months later...

Finally decided it was time to give this program a complete overhaul :)

 

Version 2.2 is a complete rewrite of the program to update many of the old subfunctions, and to reformat the code to get rid of that terrible formatting I used to use.

 

I haven't added any new functionality, but the program should be more robust and run smoother than the previous version, with a few bugs squashed in the process.

 

The Find and Replace engine has been completely rewritten, now permitting the user to use self-referencing find and replace terms (for example, replacing 'ABC' with 'AB'), and the visual feedback during the find and replace process has been improved significantly.

 

With the vast number of changes to the program, I expect there are still a few bugs lurking, but in my preliminary tests, I haven't found anything as yet (but I'm sure you guys will!).

 

Enjoy!

 

Lee

Link to comment
Share on other sites

Awesome Lee, thanks again. This is one of my most beloved programs I use practically on a daily basis. :)

 

Cheers Styk, its great to hear a program is being put to good use :)

 

Enjoy my friend :)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...