Page Layout Lisp Help

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

  1. bellenoit

    bellenoit Guest

    Can someone help me figure out how to import multiple Page setups into a drawing. I wrote the following program to remove all the existing layouts and setups then reimport them based on page size. What I am trying to do is if there are multiple pages on our drawings with different sized sheets to import the Page Setups for each size found.

    Any Ideas???

    here's the code so far...

    ;; *** Turns off Messages ***

    (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 'Print' as default ***

    (if (setq a (ssget "X" '((0 . "INSERT") (2 . "*-SIZE*"))))
    (progn
    (setq b (entget (ssname a 0))
    blkname (strcase (cdr (assoc 2 b))) ;'strcase' here...
    )))

    (cond
    ((eq blkname "B-SIZE")
    (command "LAYOUT" "T" "BBraun B-Size-2005.dwt" "Plot"
    "-PSETUPIN" "BBRAUN B-SIZE-2005.DWT" "*"
    "-PLOT" "N" "Plot" "Print" "Default Windows System Printer.pc3" "N" "Y" "N"
    )
    )
    ((eq blkname "C-SIZE")
    (command "LAYOUT" "T" "BBraun C-Size-2005.dwt" "Plot"
    "-PSETUPIN" "BBRAUN C-SIZE-2005.DWT" "*"
    "-PLOT" "N" "Plot" "Print" "Default Windows System Printer.pc3" "N" "Y" "N"
    )
    )
    ((eq blkname "C-SIZE-H")
    (command "LAYOUT" "T" "BBraun C-Size-H-2005.dwt" "Plot"
    "-PSETUPIN" "BBRAUN C-SIZE-H-2005.DWT" "*"
    "-PLOT" "N" "Plot" "Print H" "Default Windows System Printer.pc3" "N" "Y" "N"
    )
    )
    ((eq blkname "D-SIZE")
    (command "LAYOUT" "T" "BBraun D-Size-2005.dwt" "Plot"
    "-PSETUPIN" "BBRAUN D-SIZE-2005.DWT" "*"
    "-PLOT" "N" "Plot" "Print" "Default Windows System Printer.pc3" "N" "Y" "N"
    )
    )
    ((eq blkname "CP-SIZE")
    (command "LAYOUT" "T" "BBraun CP-Size.dwt" "Plot"
    "-PSETUPIN" "BBRAUN CP-SIZE.DWT" "*"
    "-PLOT" "N" "Plot" "Print H" "Default Windows System Printer.pc3" "N" "Y" "N"
    )
    )
    )

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

    ;; *** Turns on messages ***

    (setvar "cmdecho" oldcmdecho)

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

    bellenoit Guest

    is there anyway I could incorporate the following code into the above Lisp??

    (setq objgroup (ssget "x" '((0 . "INSERT"))))
    (setq count 0 bllist nil)
    (repeat (sslength objgroup)
    (setq obj (ssname objgroup count))
    (setq bname (cdr (assoc 2 (entget obj))))
    (if (not (member bname bllist))
    (setq bllist (cons bname bllist))
    )
    (setq count (+ 1 count)))

    Help!!

    noit
     
    bellenoit, Jul 15, 2004
    #2
  3. bellenoit

    devon Guest

    Hi,

    You could just import page setups from a "Plot template" drawing.

    We have this file that resides on the server and overrights all the settings when you open every drawings.

    ;;-------------------- Lisp #1
    (setq
    ;Path & filename where local standard page setups are located
    #psfile "Office - Plot Settings.dwg"
    );end setq
    ;;-------------------Lisp 2 #pgin
    (vl-load-com)
    (vlax-for PS
    (vla-get-plotconfigurations
    (vla-get-activedocument (vlax-get-acad-object)))
    (vla-delete PS))
    ;;;Code by Nauman
    (defun c:pgin (psfile / done CMDST)
    (SETQ CMDST (GETVAR "CMDECHO"))
    ;;;Save CMDECHO STATUS
    (setvar "cmdecho" 0)
    (setq done T)
    (command "PSETUPIN" psfile "*")
    ;;;Import all the Pagesetups
    (while (= (getvar "CMDNAMES") "PSETUPIN")
    (command "y" )
    (setq done nil)
    )
    ;;;end while
    (setvar "cmdecho" CMDST) ;;RESET CMDECHO Status
    (prompt (strcat "\nPlot Settings imported from " #psfile))
    (princ)
    )
    ;;;End routine
    (c:pgin #psfile)
    (princ)
    ;;----------Line in my acad.lsp or acaddoc.lsp
    (load (strcat libpref "lib/lisp/#pgin"))

    maybe this helps...

    Regards,
    Devon
     
    devon, Jul 16, 2004
    #3
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.