Results 1 to 8 of 8

Thread: A way to select a layout tab with a lisp

  1. #1
    100 Club dfuehrer's Avatar
    Join Date
    2004-11
    Posts
    128

    Default A way to select a layout tab with a lisp

    Hello everyone,

    I am hoping that someone here has a solution for me! I would like to incorporate into a lisp the ability to select a specific named layout tab in any given drawing. The kicker here is that these tabs are not named consistantly.

    They may be named "8.5 x 11" or "85x11" or "8 x 11", etc. You see what I am up against! Problem is there are hundreds of thes files in our database. The wildcard doesn't seem to work when using the LAYOUT command from the prompt so...

    Anyone have a solution??

    Thanks in advance!

    Don

  2. #2
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043

    Default Re: A way to select a layout tab with a lisp

    See if this will work for you.

    Code:
    (defun c:Test (/ ActDoc LoName)
    
    	(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
    	(vlax-for lo (vla-get-Layouts ActDoc)
    		(setq LoName (vla-get-Name lo))
    		(if
    			(and
    				(vl-string-search "8" LoName)
    				(vl-string-search "5" LoName)
    				(vl-string-search "11" LoName)
    			)
    			(vla-put-ActiveLayout ActDoc lo)
    		)
    	)
    	(princ)
    )

  3. #3
    100 Club dfuehrer's Avatar
    Join Date
    2004-11
    Posts
    128

    Talking Re: A way to select a layout tab with a lisp

    Hi Tim,

    Thanks! It does seem to work. Exactly what I was looking for!

    Don

  4. #4
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043

    Default Re: A way to select a layout tab with a lisp

    Quote Originally Posted by dfuehrer View Post
    Hi Tim,

    Thanks! It does seem to work. Exactly what I was looking for!

    Don
    You're welcome Don. You understand what it's doing right? So that if it needs to be fixed, or it switches to a layout you don't think it should, you can fix it.

  5. #5
    100 Club dfuehrer's Avatar
    Join Date
    2004-11
    Posts
    128

    Default Re: A way to select a layout tab with a lisp

    Yes, I can see how it is accomplishing the selection of the layout tab. Thanks again!

  6. #6
    100 Club CADmium's Avatar
    Join Date
    2004-08
    Location
    Eberswalde, Germany, Europe
    Posts
    128

    Default Re: A way to select a layout tab with a lisp

    a function with wcmatch to use wildcards :

    Code:
    (defun c:GOTOLAYOUT(/ LAYOUTS PATTERN KWORD)
      (setq LAYOUTS(mapcar 'strcase(cons "MODEL" (layoutlist))))
      (if(and(setq PATTERN(strcase(getstring "Layoutname (with wildcards):")))
             (/= PATTERN "")                
         )
        (progn
          (setq LAYOUTS(vl-remove-if-not '(lambda(X)(wcmatch X PATTERN))LAYOUTS))      
          (setvar "CTAB" (car LAYOUTS))
          (princ (strcat "\n" (itoa(length LAYOUTS))" layouts found."))
          (setq LAYOUTS(cdr LAYOUTS))
          (initget "Yes No")      
          (while(and LAYOUTS
                     (or(=(setq KWORD (getkword "\rNext layout ? (Yes / No)<Yes>"))"Yes")
                        (not KWORD)
                     )
                )
            (setvar "CTAB" (car LAYOUTS))
            (setq LAYOUTS(cdr LAYOUTS))
            (initget "Yes No")
          )  
        )    
      )
    )

  7. #7
    Member
    Join Date
    2013-01
    Posts
    3

    Default Re: A way to select a layout tab with a lisp

    CADmium... defun c:GOTOLAYOUT works great.
    I need to use it as a tool to automatically go trough all layouts that correspond to LALOUTS
    without user input and do something to certain viewports in the meantime.
    How do I skip user input and automaticaly go to next Layout, and where can i insert my code do be done to each Layout in LAYOUTS list?

  8. #8
    I could stop if I wanted to pbejse's Avatar
    Join Date
    2010-10
    Posts
    395

    Default Re: A way to select a layout tab with a lisp

    Quote Originally Posted by ivor.bach353091 View Post
    CADmium... defun c:GOTOLAYOUT works great.
    I need to use it as a tool to automatically go trough all layouts that correspond to LALOUTS
    LALOUTS? a layout name?

Similar Threads

  1. select result lisp modification
    By chad.beussink in forum AutoLISP
    Replies: 6
    Last Post: 2012-06-13, 07:18 AM
  2. Get a LISP to Select a Face on a 3DSolid?
    By tdswanson in forum AutoLISP
    Replies: 1
    Last Post: 2009-03-26, 10:23 PM
  3. How do I select a plotstyle for a layout?
    By JSelf in forum VBA/COM Interop
    Replies: 2
    Last Post: 2008-07-01, 03:13 PM
  4. Select only objects in the active layout
    By gdaniels in forum VBA/COM Interop
    Replies: 3
    Last Post: 2007-02-08, 09:58 PM
  5. Select by layout
    By mathew.worland in forum AutoLISP
    Replies: 2
    Last Post: 2006-01-09, 01:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •