itacad Posted May 5, 2022 Posted May 5, 2022 Hello, I have "multilayer" file where every layer is a sigle page of a dossier. Lhe layers are perfectly overlapped. To see the single pages I have to defrost the reference layer and freeze all the others. I would like to create a layout for each single layer, do you know a method or a lisp that does it automatically starting from: - dimension of the aea in space model - selected layers p.s. layer 0 is not used Thank you very much for any suggest Q71319-15-REV3 QAUT.dwg Quote
BIGAL Posted May 6, 2022 Posted May 6, 2022 My suggestion and I think you will want to have a go at coding. thaw all layers (setq lays (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))) use vlax-for lay lays vla-get-name lay setvar 'clayer lay freeze * Y layout "C" copy the 1st layout Mspace zoom e layer T * end for You need to make a title block with a mview etc for it to work. Quote
itacad Posted May 8, 2022 Author Posted May 8, 2022 Perhaps it would be sufficient to be able to create a new layout starting from a selection window on model space. but I have not found a way with the use of traditional commands, or with the search for dedicated lisp. That said, how should the code you suggest me use? should be part of a more complex lisp? Forgive me but I am not a programmer and certain suggestions from skilled people that are thought to be easy for me are not Greetings Quote
BIGAL Posted May 9, 2022 Posted May 9, 2022 (edited) I am confused by the drawing you say a layout per layer yet it does not have obvious layers, you have lots of layers 1-xx turned off but they seem to be parts. To make a layout per layer then just use VPlayer is very simple. Post a dwg with a couple of layouts made, go to mspace in viewport, use Vplayer or just use normal layer command but scroll over Vp Freeze section and can freeze / thaw a layer in a viewport. I am maybe missing something what layers to turn off / on. Edited May 9, 2022 by BIGAL Quote
BIGAL Posted May 15, 2022 Posted May 15, 2022 I think I have worked out what you want the 1st 22 layers on for all layouts, then a layout with "1" layer on only next layout "2" on and so forth up to 48. Watch this space. Quote
itacad Posted May 19, 2022 Author Posted May 19, 2022 yes, you got it right, this is the result I want to get for this file. More generally, a faster method would be enough for me to create layout. Given a window selection on model space, create a layout of equal size and with the same layer state. I recognize that it must be very difficult, I have not found anything like this after several searches. Quote
mhupp Posted May 20, 2022 Posted May 20, 2022 (edited) Ok this kinda machine guns thought the layouts. Doesn't really have any error checking and is currently only limited by the number of layouts. I also renamed the layers 01 - 09 so they sort better. (missing 02) This works off of two list the layout tabs and the layers. go to the tab you want to start unfreezing layers and type the command it will then ask you what layer to start on. type 01 if you want to do 01-48. then it steps though each layout to the right thawing the next layer on the list using the vplayer command. See attached drawing. ;;----------------------------------------------------------------------------;; ;; Unfreeze one layer per layout (defun C:foo (/ layer lay lst tab) (setvar 'cmdecho 0) (setq layer '("01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" "44" "45" "46" "47" "48") ) (setq lay (member (getstring "\nStart with Layer: ") layer)) (setq lst (member (getvar 'ctab) (layouts))) (foreach tab lst (setvar "ctab" (car lst)) (vl-cmdf "_.mspace") ;assumes one viewport per tab (vl-cmdf "_.vplayer" "T" (car lay) "" "" "") (setq lay (cdr lay)) (setq lst (cdr lst)) ) (setvar 'cmdecho 1) (princ) ) (defun Layouts (/ laylst tab lay id name) (setq laylst (massoc 350 (dictsearch (namedobjdict) "acad_layout"))) (foreach tab laylst (setq lay (entget tab)) (if (not (equal "Model" (setq Name (last (massoc 1 lay))))) (setq id (cdr (assoc 71 lay)) lst (cons (cons id name) lst) ) ) ) (setq lst (mapcar 'cdr (vl-sort lst '(lambda (x y) (< (car x) (car y)))))) ) (defun massoc (key alist / nlist) (foreach x alist (if (eq key (car x)) (setq nlist (cons (cdr x) nlist)) ) ) (reverse nlist) ) ;;----------------------------------------------------------------------------;; ;; Function to convert list to string ;; (lst2str "," lst) (defun lst2str (dlim lst / rtn) (vl-load-com) (setq rtn (car lst) lst (cdr lst)) (repeat (length lst) (setq rtn (strcat rtn dlim (car lst)) lst (cdr lst) ) ) rtn ) Q71319-15-REV3 QAUT - layers.dwg Edited May 20, 2022 by mhupp cmdecho to cut down on spam 1 Quote
BIGAL Posted May 20, 2022 Posted May 20, 2022 (edited) It was on my to do list mhupp but saved me, the 1st 22 layers need to be set to on for the layouts to make any sense, the 1-48 off, then do layouts 1-48 turning 1 only then 2 only then 3 only and so on, yes no 2 layer. Edited May 20, 2022 by BIGAL 1 Quote
Steven P Posted May 20, 2022 Posted May 20, 2022 6 hours ago, mhupp said: Ok this kinda machine guns thought the layouts. Doesn't really have any error checking and is currently only limited by the number of layouts. I also renamed the layers 01 - 09 so they sort better. (missing 02) This works off of two list the layout tabs and the layers. go to the tab you want to start unfreezing layers and type the command it will then ask you what layer to start on. type 01 if you want to do 01-48. then it steps though each layout to the right thawing the next layer on the list using the vplayer command. See attached drawing. ;;----------------------------------------------------------------------------;; ;; Unfreeze one layer per layout (defun C:foo (/ layer lay lst tab) (setvar 'cmdecho 0) (setq layer '("01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" "44" "45" "46" "47" "48") ) (setq lay (member (getstring "\nStart with Layer: ") layer)) (setq lst (member (getvar 'ctab) (layouts))) (foreach tab lst (setvar "ctab" (car lst)) (vl-cmdf "_.mspace") ;assumes one viewport per tab (vl-cmdf "_.vplayer" "T" (car lay) "" "" "") (setq lay (cdr lay)) (setq lst (cdr lst)) ) (setvar 'cmdecho 1) (princ) ) (defun Layouts (/ laylst tab lay id name) (setq laylst (massoc 350 (dictsearch (namedobjdict) "acad_layout"))) (foreach tab laylst (setq lay (entget tab)) (if (not (equal "Model" (setq Name (last (massoc 1 lay))))) (setq id (cdr (assoc 71 lay)) lst (cons (cons id name) lst) ) ) ) (setq lst (mapcar 'cdr (vl-sort lst '(lambda (x y) (< (car x) (car y)))))) ) (defun massoc (key alist / nlist) (foreach x alist (if (eq key (car x)) (setq nlist (cons (cdr x) nlist)) ) ) (reverse nlist) ) ;;----------------------------------------------------------------------------;; ;; Function to convert list to string ;; (lst2str "," lst) (defun lst2str (dlim lst / rtn) (vl-load-com) (setq rtn (car lst) lst (cdr lst)) (repeat (length lst) (setq rtn (strcat rtn dlim (car lst)) lst (cdr lst) ) ) rtn ) Q71319-15-REV3 QAUT - layers.dwg 904.08 kB · 0 downloads This works for the OP I think (not tested but I assume it does, unusual for you if it doesn't) For future and others looking at this I might be tempted to change the layer list to generate the list from what is in the drawing: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-list-of-all-layers-in-lisp/td-p/822262 . OP can add more layers as they want without worrying about the code. You might need to create an exceptions list to remove layers from the list (perhaps with a wcmatch and a vl-remove-if combination). Another option would be if this list was just numbers 1, 2, 3, 4 etc. to create it using a repeat loop and rtos that value to go into the list Both these could have user input to say start at layer 5 and end at layer 14 for example But that is just me with not a lot to do on a Friday morning and thinking too much 1 Quote
mhupp Posted May 20, 2022 Posted May 20, 2022 (edited) Yeah I saw that Steven but they way they have their layers named the list would show up as 1, 10 - 19, 2, 20 - 29, 3 Quote Both these could have user input to say start at layer 5 and end at layer 14 for example Was thinking about that. if they need it to do something like that ill update the code. -edit- Also had vplayer to turn off all layers but it was late and took it out. that's why their is lst2str in there. converting ("01" "02 ..." to "01,02..." I guess you could add it back in before mspace. was misunderstanding what All meant in the options it means all viewports on the current tab not drawing. (vl-cmdf "_.vplayer" "f" (lst2str "," layer) "all" "" "") Edited May 20, 2022 by mhupp 1 Quote
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.