Results 1 to 9 of 9

Thread: Delete a group of named layout tabs using a wildcard

  1. #1
    I could stop if I wanted to cadd4la's Avatar
    Join Date
    2001-12
    Location
    Newport Beach, CA
    Posts
    399
    Login to Give a bone
    0

    Default Delete a group of named layout tabs using a wildcard

    Hi, everyone,

    I'm in need of help deleting a group of named layout tabs in a file. I have a number of layout tabs with different names and they either ended with -24x36 or -30x42. (i.e LC-601-24x36 or LC-601-30x42). I would like to use a wildcard to delete either all the -24x36 or -30x42 tabs in the file at once.

    I've tried writing code but it will not delete any of the tabs unless I use the full name and list all the tabs that need to be deleted.

    Code:
    (defun c:DELT30x42()
    (SETVAR "CMDECHO" 0)
    (command "undo" "begin")
    (command "_Layout" "Set" "Model")
    (command "_.layout" "_d" "*-30x42")
    (command "undo" "end")
    (SETVAR "CMDECHO" 1)
    (princ))
    Thanks,

    Cadd4la

  2. #2
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    559
    Login to Give a bone
    0

    Default Re: Delete a group of named layout tabs using a wildcard

    Maybe

    Code:
    (defun c:DELT30x42()
    (SETVAR "CMDECHO" 0)
    (command "undo" "begin")
    (setvar 'ctab "Model")
    (vlax-for lay (vla-get-Layouts (vla-get-activedocument (vlax-get-acad-object)))
      (setq plotabs (cons (vla-get-name lay) plotabs))
    )
    (foreach lay plotabs
    (if (and (/= lay "Model")
             (wcmatch lay "*30x42*"))
    (command "_.layout" "_d" lay)
    )
    )
    (command "undo" "end")
    (SETVAR "CMDECHO" 1)
    (princ)
    )

  3. #3
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,665
    Login to Give a bone
    0

    Default Re: Delete a group of named layout tabs using a wildcard


  4. #4
    I could stop if I wanted to cadd4la's Avatar
    Join Date
    2001-12
    Location
    Newport Beach, CA
    Posts
    399
    Login to Give a bone
    0

    Default Re: Delete a group of named layout tabs using a wildcard

    BIG-AL,

    Thank you for your help, unfortunately, the code is not working for me, when I run it just lists the following.

    Initializing...
    Initializing...
    Initializing...
    Initializing...
    Initializing...
    Initializing...
    it keeps going with Initializing... until I press the ESC key.

    Also, can the code let me select either the 24x36 or 30x42 tabs in the same code?

    Cadd4la

    - - - Updated - - -

    Quote Originally Posted by Tom Beauford View Post
    Tom,

    Thank you as always for your input. The code is above my skill level to modify what I need it to do.

    This is as far as I can go.

    Code:
    (defun c:TABS ( / size oppLR ABC flag otherItems o)
    (initget 1 "24x36 30x42") (setq size (getkword "\n24x36 or 30x42? [24x36/30x42]"))
    (if (eq "Left" LR) (setq LR "LH" oppLR "RH") (setq LR "RH" oppLR "LH"))
    (setq otherItems (list "SALE" "COVER" "SHEET 6"));<-- add more items in quotes here
    (setq flag nil)
    (foreach l (layoutlist)
      (if (and (not (or (wcmatch (strcase l) (strcat "*(" size ")*"))
    		    (wcmatch (strcase l) (strcat "*(" ABC "-" LR ")*"))))
    	   (or (wcmatch (strcase l) (strcat "*" oppLR "*"))
    	       (wcmatch (strcase l) (strcat "*-" LR "*"))))
          (setq flag t)
      );if
      (foreach o otherItems
        (if (wcmatch (strcase l) (strcat "*" (strcase o) "*"))
          (setq flag t)
        );if
      );foreach
      (if flag
        (command "-LAYOUT" "_d" l)
      );if
      (setq flag nil)
    );foreach
    (prompt "\nComplete...")
    (princ)
    );defun
    Cadd4la

  5. #5
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    559
    Login to Give a bone
    0

    Default Re: Delete a group of named layout tabs using a wildcard

    You have confused me by adding all sorts of stuff in code that does not make sense. Did you try just my code with layouts that have -30x42.

    Code:
    (defun c:DELlay ( / lay size plotabs)
    (SETVAR "CMDECHO" 0)
    (command "undo" "begin")
    (setvar 'ctab "Model")
    
    (initget 1 "24x36 30x42") (setq size (getkword "\n24x36 or 30x42? [24x36/30x42]"))
    
    (vlax-for lay (vla-get-Layouts (vla-get-activedocument (vlax-get-acad-object)))
      (setq plotabs (cons (vla-get-name lay) plotabs))
    )
    (foreach lay plotabs
    (if (and (/= lay "Model")
             (wcmatch lay size))
    (command "_.layout" "_d" lay)
    )
    )
    (command "undo" "end")
    (SETVAR "CMDECHO" 1)
    (princ)
    )

  6. #6
    I could stop if I wanted to cadd4la's Avatar
    Join Date
    2001-12
    Location
    Newport Beach, CA
    Posts
    399
    Login to Give a bone
    0

    Default Re: Delete a group of named layout tabs using a wildcard

    BIG-AL,

    Sorry for the confusion, the code I posted was for Tom and a reply to the link he posted and not for you.

    That said, your code is not working, when I run your code it will change to the model tab and list the 24x36 or 30x42 for me to select but after I select one of them it does nothing.

    Please remember from my first post.
    I have a number of layout tabs with different names and they either ended with -24x36 or -30x42. (i.e LC-601-24x36 or LC-601-30x42). I would like to use a wildcard to delete either all the -24x36 or -30x42 tabs in the file at once.
    I don't have any tabs in the file with just -24x36, -30x42, 24x36, or 30x42.

    Cadd4la

  7. #7
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,100
    Login to Give a bone
    0

    Default Re: Delete a group of named layout tabs using a wildcard

    Try this
    Code:
    (defun c:DeleteLayouts (/ DeleteTheseLayouts TriggerName)
      ;; Initialize user input options
      (initget 1 "24x36 30x42")
      ;; Request user input
      (setq TriggerName (getkword "\n24x36 or 30x42? [24x36/30x42]"))
      ;; Set current layout to the Model tab
      (setvar 'ctab "Model")
      ;; Cycle through all of the layouts
      (vlax-for layout (vla-get-layouts
                         (vla-get-activedocument (vlax-get-acad-object))
                       )
        ;; If not the model layout tab
        (if (not (= (vla-get-name layout) "Model"))
          ;; If trigger name is found
          (if (and (vlax-property-available-p layout 'name)
                   (wcmatch (strcase (vla-get-name layout))
                            (strcat "*" (strcase TriggerName) "*")
                   )
              )
            ;; Delete this layout
            (vl-catch-all-apply 'vla-delete (list layout))
          )
        )
      )
    )
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  8. #8
    I could stop if I wanted to cadd4la's Avatar
    Join Date
    2001-12
    Location
    Newport Beach, CA
    Posts
    399
    Login to Give a bone
    0

    Default Re: Delete a group of named layout tabs using a wildcard

    Opie,

    It works great. thanks for your help.

    Cadd4la

  9. #9
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    559
    Login to Give a bone
    0

    Default Re: Delete a group of named layout tabs using a wildcard

    I tested against layout1 layout2 -> etc i just looked for "out" it may be a caps problem with X. Just looked yes its case sensitive. 30X42 is different to 30x42 so strcase it.

    Code:
    (defun c:DELT30x42()
    (SETVAR "CMDECHO" 0)
    (command "undo" "begin")
    (setvar 'ctab "Model")
    (vlax-for lay (vla-get-Layouts (vla-get-activedocument (vlax-get-acad-object)))
      (setq plotabs (cons (vla-get-name lay) plotabs))
    )
    (foreach lay plotabs
    (if (and (/= lay "Model")
             (wcmatch (strcase lay) "*30X42*"))
    (command "_.layout" "_d" lay)
    )
    )
    (command "undo" "end")
    (SETVAR "CMDECHO" 1)
    (princ)
    )

Similar Threads

  1. Delete layout tabs
    By cadd4la in forum AutoLISP
    Replies: 11
    Last Post: 2020-01-15, 04:39 AM
  2. Help! I do not want to delete my layout tabs
    By Jgoduti25 in forum AutoLISP
    Replies: 4
    Last Post: 2013-12-18, 03:31 AM
  3. Add NAMED VIEWS to publish command as current LAYOUT tabs are.
    By Wish List System in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2012-03-22, 06:04 PM
  4. Delete Layout tabs in script?
    By ecochic in forum AutoCAD General
    Replies: 4
    Last Post: 2007-09-26, 04:24 PM
  5. Named Viewports on Layout Tabs
    By Scott.Baumann in forum AutoCAD General
    Replies: 7
    Last Post: 2005-05-13, 02:51 PM

Tags for this Thread

Posting Permissions

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