Almost there Layout replace

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

  1. bellenoit

    bellenoit Guest

    Ok, I am about 99% done with this lisp I've been working on... what it does is remove all Layouts and Pagesetups then replace them with our standard ones based on out Titleblock sizes... only problem I have now is if it finds a duplicate page setup name it prompts you if you would like to replace it or not...

    OK now the question is how can I get around this prompting??? ... I don't want it to replace them, and I don't want to have my users hit "No" 3 times to end the lisp... (I added the three "N"s to the command line just to end the command!!!)

    suggestions? Solutions???

    here's the code...

    ;; *** Turns off Messages ***

    (setq oldnomutt (getvar "nomutt"))
    (setvar "nomutt" 1)
    (setq oldcmdecho (getvar "cmdecho"))
    (setvar "cmdecho" 0)


    ;; *** 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 defaults ***

    (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 n (sslength a))
    (setq index 0)
    (repeat n
    (setq b (entget (ssname a index)))
    (setq blkname (cdr (assoc 2 b)))
    (if (= (strcase blkname T) "b-size")(command "LAYOUT" "T" "BBraun B-Size-2005.dwt" "*"
    "-PSETUPIN" "BBRAUN B-SIZE-2005.DWT" "*" "N" "N" "N"))
    (if (= (strcase blkname T) "c-size")(command "LAYOUT" "T" "BBraun C-Size-2005.dwt" "*"
    "-PSETUPIN" "BBRAUN C-SIZE-2005.DWT" "*" "N" "N" "N"))
    (if (= (strcase blkname T) "c-size-h")(command "LAYOUT" "T" "BBraun C-Size-H-2005.dwt" "*"
    "-PSETUPIN" "BBRAUN C-SIZE-H-2005.DWT" "*" "N" "N" "N"))
    (if (= (strcase blkname T) "d-size")(command "LAYOUT" "T" "BBraun D-Size-2005.dwt" "*"
    "-PSETUPIN" "BBRAUN D-SIZE-2005.DWT" "*" "N" "N" "N"))
    (if (= (strcase blkname T) "cp-size")(command "LAYOUT" "T" "BBraun CP-Size.dwt" "*"
    "-PSETUPIN" "BBRAUN CP-SIZE.DWT" "*" "N" "N" "N"))
    (setq index (1+ index))
    )

    ;; *** Deletes the default "Layout1" Tab

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

    ;; *** Turns on messages ***

    (setvar "cmdecho" oldcmdecho)
    (setvar "nomutt" oldnomutt)
    (princ)
     
    bellenoit, Jul 16, 2004
    #1
  2. bellenoit

    ECCAD Guest

    During your loop:
    (repeat n...
    you could build a 'list' of the blocks found..
    and, check if you already have (this) blockname on the list.
    (if (not (member blk lst))
    (progn
    (do the layout commands)
    )
    )

    Bob
     
    ECCAD, Jul 16, 2004
    #2
  3. bellenoit

    bellenoit Guest

    That would only work when I don't have multiple sheets... but if we have a drawing that has a B-size sheet and a C-size sheet it will still give me the prompt to replace... hence the problem...
     
    bellenoit, Jul 16, 2004
    #3
  4. bellenoit

    ECCAD Guest

    No,
    That (would) work. The 'block names' you are looking for are unique. Do your layout command, place the blockname on the list. Next loop. IF (not member.. will check if you already did that particular block..if not, will do layout stuff.

    Bob
     
    ECCAD, Jul 16, 2004
    #4
  5. bellenoit

    bellenoit Guest

    Ok I see what your saying, but we do have instances where we will have multiple sheets of the same size... and currently it puts as many tabs as there are sheets... which is what we want to happen... I hope im not confusing you... I am getting confused with this thing already!

    Thanks for the help though!!
     
    bellenoit, Jul 16, 2004
    #5
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.