Lee Mac 发表于 2022-7-6 15:18:50

This might be useful to you:

http://web2.airmail.net/terrycad/AutoLISP-Code.htm
 
Top one ^^

CAB 发表于 2022-7-6 15:21:41

Another:

;; 07/14/2005CAB(defun C:TabSort (/ cnt doc lay) (vl-load-com) (setq cnt 1       doc (vla-get-activedocument (vlax-get-acad-object))       ) (foreach lay (acad_strlsort (vl-remove "Model" (layoutlist)))   (vla-put-taborder (vla-item (vla-get-layouts doc) lay) cnt)   (setq cnt (1+ cnt)) ) (princ))

CAB 发表于 2022-7-6 15:24:43

;; --------------------------------------------------------------------------- ;; Function: tabsort ;; Purpose : sort Tabs by the prefix then the first numbers found ;; AUTHORCharles Alan Butler @ TheSwamp.org;; --------------------------------------------------------------------------- ;; Last Update 03/01/2006CAB(defun C:TabSort (/ cnt doc lay) (vl-load-com) ;; ---------------------------------------------------------------------------;; Function: Num_sort;; Purpose : sort list of strings by the prefix then the first numbers found;; AUTHORCharles Alan Butler @ TheSwamp.org ;; Params: tablst:    list of strings to sort ;; Returns : sorted list ;; ---------------------------------------------------------------------------(defun Num_Sort (tablst / tab ptr len loop tmp tmp2 sub lst)   (defun vl-sort-it (lst func)   (mapcar '(lambda (x) (nth x lst)) (vl-sort-i lst func))   )   (defun sort2 (tmp2 sub)   (setq tmp2 (append                  (vl-sort-it sub '(lambda (e1 e2) (< (cadr e1) (cadr e2))))                  tmp2                )   )   )   ;;convert to a list (string) -> (prefix num string)   (foreach tab tablst   (setq ptr1         len(strlen tab)         loop t   )   (while loop       (cond         ((wcmatch "0123456789" (strcat "*" (substr tab ptr 1) "*"))          (setq tmp(cons (list (substr tab 1 (1- ptr))                                 (atof (substr tab ptr))                                 tab                           )                           tmp                     )                loop nil          )         )         ((> (setq ptr (1+ ptr)) len)          ;;no number in string          (setq tmp(cons (list tab nil tab) tmp)                loop nil          )         )       )                     ; end cond stmt   )   )   ;;sort on the prefix   (setq tmp (vl-sort-it tmp '(lambda (e1 e2) (< (car e1) (car e2)))))   ;; Do a number sort on each group of matching prefex   (setq idx (length tmp))   (while (> (setq idx (1- idx)) -1)   (cond       ((not sub)      (setq sub (List (nth idx tmp))            str (car (nth idx tmp))      )       )       ((= (car (nth idx tmp)) str) ; still in the group      (setq sub (cons (nth idx tmp) sub))       )   )                     ; end cond stmt   (if (= idx 0)         ; end of list       (progn         (setq tmp2 (sort2 tmp2 sub))         (if (/= (car (nth idx tmp)) str)         (setq tmp2 (append (list (nth idx tmp)) tmp2))         )         (setq str (car (nth idx tmp)))       )   )   (if (/= (car (nth idx tmp)) str)       ;; next group, so sort previous group       (setq tmp2 (sort2 tmp2 sub)             sub(list (nth idx tmp))             str(car (nth idx tmp))       )   )   )                         ; end while   (setq lst (mapcar 'caddr tmp2))   (princ)   lst )                           ; end defun ;;========================================================================== (setq cnt 1       doc (vla-get-activedocument (vlax-get-acad-object)) ) (foreach lay (num_sort (vl-remove "Model" (layoutlist)))   (vla-put-taborder (vla-item (vla-get-layouts doc) lay) cnt)   (setq cnt (1+ cnt)) ) (princ))                           ; end defun(prompt "\nTabSort loaded, enter TabSort to run.")(princ)

Lee Mac 发表于 2022-7-6 15:27:35

Nice CAB.
 
Just goes to show what they say about coding these things - its all been done before

ChrisCMU 发表于 2022-7-6 15:33:00

I'm having a hard time figuring out how to configure things right.It says to:
 
"Change the following global lists *PlotterInfo@ and *PlotStyles@ to suit the specifications of each AutoCAD department"
 
Where are those lists?sorry, I'm a little lost.

ChrisCMU 发表于 2022-7-6 15:35:52

 
 
When I had 2007 I could find that file in the programs folder.Now I have 2010 and I cannot find it anywhere.If I do a windows search it does not show up (even including hidden files).I see "acad2010.lsp" and "acad2010doc.lsp" but the help file says you should not edit the second one for whatever reason:
 
I thought maybe they got rid of the acaddoc.lsp and just want you to change the ACADLSPASDOC setting to load the regular one on start up.But then it says this in the help file (in addition to mentioning it above): 
So that file must exist still.how come I can't find it?

lpseifert 发表于 2022-7-6 15:39:48

The acaddoc.lsp does not come with the installation of Acad. It's just a text file easily created with Notepad.

Lee Mac 发表于 2022-7-6 15:43:10

Just create an ACADDOC.lsp with Notepad (save it as a .lsp file and put it in your search path file)
页: 1 [2]
查看完整版本: Re-ordering layout tabs?