Config Page Layouts Help

Discussion in 'AutoCAD' started by bellenoit, Jul 13, 2004.

  1. bellenoit

    bellenoit Guest

    I wrote this lisp (with alot of help from here!) to delete all the Pagesetups and Layout tabs on our drawings then reset them to our defaults... can anyone tell me how to get this thing to run more silently (it flashes and echos on the command line)

    Thanks!!!

    ;; *** Deletes Page Setups

    (defun Delset ()
    (vl-load-com)
    (vlax-for y (vla-get-plotconfigurations (vla-get-activedocument (vlax-get-acad-object)))
    (if (/= "Model" (vla-get-name y))(vla-delete y))
    )
    )
    (Delset)


    ;; *** Deletes Page Layouts

    (defun DelTabs ()
    (vl-load-com)
    (vlax-for x (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))
    (if (/= "Model" (vla-get-name x)) (vla-delete x))
    )
    )
    (deltabs)


    ;; *** Calls in current layout tabs based on size ***
    ;; *** Adds Default Setups and sets 'Print' as default ***

    (setq a (ssget "X"
    '((-4 . "<OR")
    (-4 . "<AND")
    (0 . "Insert")
    (2 . "B-SIZE")
    (-4 . "AND>")
    (-4 . "<AND")
    (0 . "Insert")
    (2 . "C-SIZE")
    (-4 . "AND>")
    (-4 . "<AND")
    (0 . "Insert")
    (2 . "C-SIZE-H")
    (-4 . "AND>")
    (-4 . "<AND")
    (0 . "Insert")
    (2 . "CP-SIZE")
    (-4 . "AND>")
    (-4 . "<AND")
    (0 . "Insert")
    (2 . "D-SIZE")
    (-4 . "AND>")
    (-4 . "OR>"))
    )
    )
    (setq b (entget (ssname a 0)))
    (setq blkname (cdr (assoc 2 b)))
    (if (= (strcase blkname T) "b-size")(command "layout""T""BBraun B-Size-2005.dwt""Plot"))
    (if (= (strcase blkname T) "b-size")(command "-PSETUPIN" "BBRAUN B-SIZE-2005.DWT" "*"))
    (if (= (strcase blkname T) "c-size")(command "layout""T""BBraun C-Size-2005.dwt""Plot"))
    (if (= (strcase blkname T) "c-size")(command "-PSETUPIN" "BBRAUN C-SIZE-2005.DWT" "*"))
    (if (= (strcase blkname T) "c-size-h")(command "layout""T""BBraun C-Size-H-2005.dwt""Plot"))
    (if (= (strcase blkname T) "c-size-h")(command "-PSETUPIN" "BBRAUN C-SIZE-H-2005.DWT" "*"))
    (if (= (strcase blkname T) "d-size")(command "layout""T""BBraun D-Size-2005.dwt""Plot"))
    (if (= (strcase blkname T) "d-size")(command "-PSETUPIN" "BBRAUN D-SIZE-2005.DWT" "*"))

    ;sets your PS current in Plot tab
    (command "-PLOT" "N" "Plot" "Print" "Default Windows System Printer.pc3" "N" "Y" "N")

    (vla-Delete(vla-Item(vla-Get-Layouts(vla-Get-ActiveDocument(vlax-Get-Acad-Object)))"Layout1"))

    (princ)
     
    bellenoit, Jul 13, 2004
    #1
  2. bellenoit

    Tom Smith Guest

    more silently (it flashes and echos on the command line)

    Turn off cmdecho at the beginning of the routine. If there are still prompts
    or messages visible, turn on nomutt. Don't forget to turn off nomutt again
    at the end.
     
    Tom Smith, Jul 13, 2004
    #2
  3. bellenoit

    bellenoit Guest

    Thanks Tom that'll do it!

    noit
     
    bellenoit, Jul 14, 2004
    #3
  4. bellenoit

    Jürg Menzi Guest

    Hi bellenoit

    You can make some of your code more efficient:

    (setq a (ssget
    "X"
    '((0 . "INSERT") (2 . "B-SIZE,C-SIZE,C-SIZE-H,CP-SIZE,D-SIZE"))
    )
    )
    ....
    or (if there are no other blocks with the name '*-SIZE*'):
    (setq a (ssget "X" '((0 . "INSERT") (2 . "*-SIZE*"))))
    ....
    it's also better to use an if condition to avoid errors when missing the
    block:
    (if (setq a (ssget "X" '((0 . "INSERT") (2 . "*-SIZE*"))))
    (progn
    ...
    one 'setq' is enough for multiple var's:
    (setq b (entget (ssname a 0))
    blkname (strcase (cdr (assoc 2 b))) ;'strcase' here...
    )
    ....
    use 'cond' instead of if to make things easier and more readable:
    (cond
    ((eq blkname "B-SIZE")
    (command "LAYOUT" "T" "BBraunB-Size-2005.dwt" "Plot"
    "-PSETUPIN" "BBRAUN B-SIZE-2005.DWT" "*"
    )
    )
    ((eq blkname "C-SIZE")
    (command "LAYOUT" "T" "BBraunC-Size-2005.dwt" "Plot"
    "-PSETUPIN" "BBRAUN C-SIZE-2005.DWT" "*"
    )
    )
    ((eq blkname "C-SIZE-H")
    (command "LAYOUT" "T" "BBraunC-Size-H-2005.dwt" "Plot"
    "-PSETUPIN" "BBRAUNC-SIZE-H-2005.DWT" "*"
    )
    )
    ((eq blkname "D-SIZE")
    (command "LAYOUT" "T" "BBraunD-Size-2005.dwt" "Plot"
    "-PSETUPIN" "BBRAUN D-SIZE-2005.DWT" "*"
    )
    )
    )
    ....
    BTW, what are you doing with block name CP-SIZE?

    Cheers
     
    Jürg Menzi, Jul 14, 2004
    #4
  5. bellenoit

    bellenoit Guest

    Even Better!!! thanks!!! and I did notice I forgot the CP-Size in the list... I made your changes and workin through some other lisp's I have done to "streamline"!!!

    noit
     
    bellenoit, Jul 14, 2004
    #5
  6. bellenoit

    Jürg Menzi Guest

    Hi Noit

    Glad to help you...¦-)

    Cheers
     
    Jürg Menzi, Jul 14, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.