rcb007 Posted June 5, 2020 Share Posted June 5, 2020 I have several layout tabs in drawing, and I need to go through each tab to adjust the scale and layers, then go on to the next. I am trying to manually do it within the code, but did not know how to make it loop to the last layout tab. (defun C:AMVP_Part3() ;;Viewport 1 (command "-layout" "set" "C3.1") (command "-layer" "Freeze" "xMatchline*" "Thaw" "*Area1" "") (command "_mspace") (command "zoom" "extents") (command "ZOOM" "Scale" "1/20xp") (command "_pspace") ;;Viewport 2 (command "-layout" "set" "C3.2") (command "-layer" "Freeze" "xMatchline*" "Thaw" "*Area2" "") (command "_mspace") (command "zoom" "extents") (command "ZOOM" "Scale" "1/20xp") (command "_pspace") ;;Viewport 3 (command "-layout" "set" "C3.3") (command "-layer" "Freeze" "xMatchline*" "Thaw" "*Area3" "") (command "_mspace") (command "zoom" "extents") (command "ZOOM" "Scale" "1/20xp") (command "_pspace") ;;Viewport 4 (command "-layout" "set" "C3.4") (command "-layer" "Freeze" "xMatchline*" "Thaw" "*Area4" "") (command "_mspace") (command "zoom" "extents") (command "ZOOM" "Scale" "1/20xp") (command "_pspace") (princ)) this goes all the way to 30 layout tabs. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted June 5, 2020 Share Posted June 5, 2020 Try something like this: (foreach name (layoutlist) (setvar 'ctab name) (command "-layer" "Freeze" "xMatchline*" "Thaw" "*Area2" "") (command "_mspace") (command "zoom" "extents") (command "ZOOM" "Scale" "1/20xp") (command "_pspace") ) Quote Link to comment Share on other sites More sharing options...
rcb007 Posted June 5, 2020 Author Share Posted June 5, 2020 (edited) Thanks man!. That piece helps out a lot! Saves a lot of extra anticipating code. I forgot to mention this piece. I apologize. with the (command "-layer" "Freeze" "xMatchline*" "Thaw" "*Area1" "") So how would this work if I needed the first tab be to turn on "*Area1" Then the next time would be "*Area2" and so forth? If it cant, I its not the end of the world. Edited June 5, 2020 by rcb007 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted June 5, 2020 Share Posted June 5, 2020 (edited) Here is one way untested: (defun c:foo (/ n) (setvar 'cmdecho 0) (foreach name (layoutlist) (setvar 'ctab name) (setq n (cdr (assoc -1 (dictsearch (namedobjdict) "acad_layout")))) (command "-layer" "Freeze" "xMatchline*" "Thaw" (strcat "*Area" (itoa (cdr (assoc 71 (dictsearch n name))))) "" ) (command "_mspace") (command "zoom" "extents") (command "ZOOM" "Scale" "1/20xp") (command "_pspace") ) (setvar 'cmdecho 1) (princ) ) Here's a VL version for your edumacation: (defun c:foo nil (setvar 'cmdecho 0) (vlax-for lyt (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object))) (if (= 0 (vlax-get lyt 'modeltype)) (progn (setvar 'ctab (vla-get-name lyt)) (command "-layer" "Freeze" "xMatchline*" "Thaw" (strcat "*Area" (itoa (vla-get-taborder lyt))) "" ) (command "_mspace") (command "zoom" "extents") (command "ZOOM" "Scale" "1/20xp") (command "_pspace") ) ) ) (setvar 'cmdecho 1) (princ) ) (vl-load-com) Edited June 5, 2020 by ronjonp Quote Link to comment Share on other sites More sharing options...
rcb007 Posted June 5, 2020 Author Share Posted June 5, 2020 It works great! Thank you again. Saves so much time! Quote Link to comment Share on other sites More sharing options...
ronjonp Posted June 5, 2020 Share Posted June 5, 2020 2 minutes ago, rcb007 said: It works great! Thank you again. Saves so much time! Glad to help out Quote Link to comment Share on other sites More sharing options...
rcb007 Posted July 29, 2020 Author Share Posted July 29, 2020 Gotta a question. I am trying to configure the same code not to use the xref. I thought all I had to do was remove the "Matchline" part of the code, but does it need to be there or replaced with a (*)? (defun c:foo (/ n) (setvar 'cmdecho 0) (foreach name (layoutlist) (setvar 'ctab name) (setq n (cdr (assoc -1 (dictsearch (namedobjdict) "acad_layout")))) (command "-layer" "Freeze" "*" <--- How to remove the Xref Name and just use the layers within the drawing? "Thaw" (strcat "*Area" (itoa (cdr (assoc 71 (dictsearch n name))))) "" ) (command "_mspace") (command "zoom" "extents") (command "ZOOM" "Scale" "1/20xp") (command "_pspace") ) (setvar 'cmdecho 1) (princ) ) Quote Link to comment Share on other sites More sharing options...
ronjonp Posted July 29, 2020 Share Posted July 29, 2020 You want to freeze all xref layers ( "*|*" ) or exclude xref layers ( "~*|*" ) ? Quote Link to comment Share on other sites More sharing options...
rcb007 Posted July 29, 2020 Author Share Posted July 29, 2020 Currently when I run the routine it works like it should with the matchline xref attached in the sheet. If I were to bind the xref into the sheet dwg (as a block) and run the routine, it does not seem to work as it does if it was an xref. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted July 29, 2020 Share Posted July 29, 2020 Post a sample drawing .. I'm not following what you're trying to do. If you bind a drawing the layer names change based on your BINDTYPE system variable. Just Guessing use: "*xMatchline*" Quote Link to comment Share on other sites More sharing options...
rcb007 Posted July 29, 2020 Author Share Posted July 29, 2020 (edited) Ronjonp, I don't know what I did, but I got it working. I guess I had to reboot my pc, but its working. Edited July 30, 2020 by rcb007 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted July 30, 2020 Share Posted July 30, 2020 On 7/29/2020 at 12:15 PM, rcb007 said: Ronjonp, I don't know what I did, but I got it working. I guess I had to reboot my pc, but its working. 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.