gsc Posted June 22, 2018 Share Posted June 22, 2018 Hi, I have a LISP routine which creates Layout TAB's based on a list (id_list). (setq cnt 0) (repeat (1- (length id_list)) (progn (setvar "ctab" (nth cnt id_list)) (command "-layout" "copy" (nth cnt id_list) (nth (1+ cnt) id_list)) (setvar "ctab" (nth (1+ cnt) id_list)) (setq cnt (1+ cnt)) ) ) I want the sorting of the TABs according to the id_list, but Autocad is using its own TAB sorting based on the Name. Is there a setting to turn this off, or maybe a lisp trick? If I do this manually with "Move or Copy" there is the option "move to end", this option is not available when the command line function -LAYOUT is used. Quote Link to comment Share on other sites More sharing options...
dlanorh Posted June 22, 2018 Share Posted June 22, 2018 http://www.cadtutor.net/forum/archive/index.php/t-35683.html Quote Link to comment Share on other sites More sharing options...
gsc Posted June 22, 2018 Author Share Posted June 22, 2018 But are those examples not sorting Alphabetically? I want to sort according to a list (which is not Alphabetically) Quote Link to comment Share on other sites More sharing options...
dlanorh Posted June 22, 2018 Share Posted June 22, 2018 But are those examples not sorting Alphabetically? I want to sort according to a list (which is not Alphabetically) Use the following lisp defun to create the layouts (defun rh:addlayout ( l_list / c_doc layouts) (vl-load-com) (setq c_doc (vla-get-activedocument (vlax-get-acad-object)) layouts (vla-get-layouts c_doc) );end_setq (foreach l_name l_list (vla-add layouts l_name) ) ) Paste the above code at the top of your lisp, comment out the code you posted above and paste above the commented out code (rh:addlayout id_list) any problems then please post your entire lisp. I'm very busy at the moment but will look at it later today Quote Link to comment Share on other sites More sharing options...
gsc Posted June 22, 2018 Author Share Posted June 22, 2018 It is a little bit different. I already have a drawing with 1 layout TAB, which I want to copy and rename multiple times based on the CSV file. Besides copying and renaming the previous layout, it also shifts the VPORT to the corresponding location in the model space. 1. Open DWG 2. run lisp 3. select layout from list 4. select the CSV file The problem is the sorting of the tabs should be according the CSV file Notes: The lisp is a modified version of another lisp I have, so I still need to clean up the stuff which is not used The CSV file will be different for each project, in the previous project the id_list coincidentally was alphabetically, so I wasn't aware of the sorting problem. Test.dwg Create Multiple WTG Sheets.lsp Create Multiple WTG Sheets.csv Quote Link to comment Share on other sites More sharing options...
dlanorh Posted June 22, 2018 Share Posted June 22, 2018 Please find attached your updated lisp. I have added some local variables to allow the layout order to be changed. The re-ordering of the layout tabs relies on there only being two tabs, "model" and the (baselay) tab that starts the copying. If there more, these tabs will be shifted to the end. I have also commented out (princ id_list) as it isn't really needed and the DTR function as it isn't used. I'll look into a more efficient way of copying and ordering the layouts. Create Multiple WTG Sheets.lsp Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 22, 2018 Share Posted June 22, 2018 Something else that may be useful is (vla-get-taborder) thie is the actual order not by name. Quote Link to comment Share on other sites More sharing options...
dlanorh Posted June 23, 2018 Share Posted June 23, 2018 (edited) Please find attached an updated version of your lisp. I've added error checking so needed to split writing the dcl from showing the dcl. I've hard coded the Dialog Title and made it single selection only, as a multiple selection would mean 2 or more template layouts! I've also allowed for an automatic selection of the layout template if there is only one item in the list of layouts. Otherwise the OK button is disabled until a choice is made from the list. I've combined reading the csv file with creating the layout copies inside a while loop. I've commented my code as to what does what. Basically i create a new layout, then clone every paperspace object from the template layout to the new layout, copy the properties across and then enter the viewport and perform the pan. The layouts don't need sorting and stay in their creation order. I have noticed that the template layout has an extension dictionary. I haven't copied this over, but should I? MWS2.lsp Edited June 23, 2018 by dlanorh wrong version of file attached Quote Link to comment Share on other sites More sharing options...
gsc Posted June 25, 2018 Author Share Posted June 25, 2018 Thanx man, works like a charm...this is much more than I expected! Quote Link to comment Share on other sites More sharing options...
dlanorh Posted June 25, 2018 Share Posted June 25, 2018 My pleasure. Any feedback on the extension dictionary Quote Link to comment Share on other sites More sharing options...
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.