Results 1 to 5 of 5

Thread: Create layout and change its page setup

  1. #1
    Member
    Join Date
    2013-11
    Posts
    4
    Login to Give a bone
    0

    Default Create layout and change its page setup

    Hello guys,
    I've modified and created lisp, that creates layout with viewport zoomed to selected rectangle/block from modelspace.
    But now I'm having issues with modifying its page setup. I'm not that good with vla or lisp at all, so I would appreciate any help!

    Code:
    ;Creates Layouts, by predefining Sheetsize and Orientation,
    ; and continious frame picking(rectangle/block) with name input for each layout
    
    
    (defun C:VLD_LAYOUT2 (/ OBJ1 SHTSIZE LNAME1 layoutObj ssVP)
      (vl-load-com)
      (setq acadApp (vlax-get-Acad-object))
      (setq acadDoc (vla-get-ActiveDocument acadApp))
      (setq layouts (vla-get-Layouts acadDoc))
      (COMMAND "PSLTSCALE" "0")
    
    
    ;*PREDEFINING SHEETSIZE:
        (initget "A4 A3 A2 A1 A0")
        (setq SHTSIZE
            (cdr
                (assoc (cond ((getkword "\nChoose [A4/A3/A2/A1/A0] <A4>: ")) ("A4"))
                   '(
                        ("A4" . "ISO full bleed A4 (297.00 x 210.00 MM)")
                        ("A3" . "ISO full bleed A3 (420.00 x 297.00 MM)")
                        ("A2" . "ISO full bleed A2 (594.00 x 420.00 MM)")
                        ("A1" . "ISO full bleed A1 (841.00 x 594.00 MM)")
                        ("A0" . "ISO full bleed A0 (841.00 x 1189.00 MM)")
                    )
                )
            )
        )
    ;*PREDEFINING ORIENTATION:
    ;   (initget "Landscape Portrait")
    ;   (setq OR-LP (cond ((getkword "\nChoose [Landscape/Portrait] <Landscape>: ")) ("Landscape"))) ;Haven't figured out how to assign this to pagesetup
    
    
    ;*CONTINIOUS OBJECT SELECTION AND NAME INPUT FOR EACH LAYOUT:
       (while (setq OBJ1 (ssget "_:S:E" '((0 . "INSERT,LWPOLYLINE"))))
            (vla-getboundingbox (vlax-ename->vla-object (ssname OBJ1 0)) 'mn 'mx)
       (setq LNAME1 (getstring "\nSpecify Layout name:"))
    
    
    ;*DELETE THE LAYOUT NAMED LNAME1 IF IT EXISTS:
      (vlax-for objLayout layouts
        (if (= (vla-get-name objLayout) LNAME1)
          (progn
            (princ
              (strcat "\nDeleted Layout named "
                  (vla-get-name objLayout) "..."
              )
            )
            (vla-delete objLayout) ;delete the Layout
            (vlax-release-object objLayout) ; release the Layout Object
          );progn
        );if
      ) ;vlax-for
    
    
    ;*CREATE THE NEW LAYOUT, NAMED LNAME1: 
      (setq layoutObj (vla-add layouts LNAME1))
    
    
    ;*MAKE THE NEW LAYOUT ACTIVE:
     (if (/= LNAME1 (getvar 'ctab))
         (setvar 'ctab LNAME1)
     )
    
    
    ; (vla-put-activelayout acadDoc layoutObj) ; Alternate vla method
    ;  (COMMAND "_.LAYOUT" "NEW" LNAME1) ; Alternate non-vla method
    ;  (COMMAND "_.LAYOUT" "SET" LNAME1) ; Alternate non-vla method
    
    
    ;*ASSIGN BLACK-GRAY-WHITE.CTB TO THE LAYOUT:
      (vla-put-StyleSheet layoutObj "BLACK-GRAY-WHITE.CTB")
    
    
    ;*ASIGN DWF CONFIGURATION TO THE LAYOUT:
      (if (= (substr (vlax-variant-value (vla-getvariable acadDoc "ACADVER")) 1 2) "15")
        (vla-put-configname layoutObj "PublishToWeb DWF.pc3") 
        (vla-put-configname layoutObj "DWG To PDF.pc3")
      ) ;if
    
    
    ;*ASSIGN THE DEFINED SHEETSIZE TO THE LAYOUT: 
      (vla-put-canonicalmedianame layoutObj SHTSIZE)
    
    
    ;*DELETES THE INITIAL VIEWPORT, FROM THE CREATED LAYOUT:
       (setq ssVP
       (ssget "_x"
       (list '(0 . "VIEWPORT") (cons 410 (getvar 'ctab)))
       )
       )
       (command "erase" ssVP "")
    
    
    ;*CREATES NEW VIEWPORT FOR THE LAYOUT:
       (COMMAND "_.VPORTS" "FIT")
    
    
       (COMMAND "_.MSPACE")
       (command "_.ZOOM"
       (trans (vlax-safearray->list mn) 0 1)
       (trans (vlax-safearray->list mx) 0 1)
       )
       (COMMAND "_.PSPACE")
       (COMMAND "_.CTAB" "MODEL")
       ) ;end of while
       (princ)
    )

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

    Default Re: Create layout and change its page setup

    Seems like the hard way. Why not just import a layout from a template that has already been set up?
    This macro uses Lee Mac's "StealV1-6.lsp" to import the "11×17" from my Templates.dwt.
    Code:
    ^C^C^P(or C:Steal (load "StealV1-6.lsp"))(Steal (strcat (vl-filename-directory (getenv "QnewTemplate")) (chr 92) "Templates.dwt") '(("Layouts" "11×17"))) .regen
    You can do it with a macro using the Layout command.

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Create layout and change its page setup

    Regardless of how you import the named Page Setup, the issue of applying it to one or more Layout is why I developed the following custom LispFunction Method:

    http://forums.augi.com/showthread.ph...=1#post1219546

    Example:
    Code:
    (foreach layoutname (layoutlist)
      (vla-SetActivePageSetup layoutname “YourPageSetupName”)
    )
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  4. #4
    Member
    Join Date
    2013-11
    Posts
    4
    Login to Give a bone
    0

    Default Re: Create layout and change its page setup

    Hello Tom,
    I'm not sure that I want to import layouts from my other drawings, since on every project I have layouts named like: 1-13, 2-13, 3-13, 4-13... 13-13 with different page setup on each (depending on my needed sheetsize).
    I already have similar lisp that quickly plots from modelspace to pdf (where I choose my sheetsize & orientation - and then just pick rectangles or blocks and the routine directly plots them).
    But my goal on this one is, instead of plot - to create layout for that same rectang/block, so I would skip those 10+ regular clicks and the delay between each plot (and once done - use 2nd lisp to plot all my layouts), everytime I need to send drawings in .pdf format.

    Hello BlackBox,
    Thank you for your recommendation, I'll check this thread.

  5. #5
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Create layout and change its page setup

    In lieu of printing via LISP, for a much faster result, consider the Autopublish mechanism.

    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Similar Threads

  1. 2014: Page setup manager - Import layout names missing
    By tmillman437483 in forum AutoCAD LT - General
    Replies: 1
    Last Post: 2015-03-27, 07:16 PM
  2. 2013: How do I create multiple copies of a page layout at once?
    By markdunavant in forum AutoCAD LT - General
    Replies: 2
    Last Post: 2013-01-25, 01:11 PM
  3. Any way to lock down a layout / page setup?
    By michael.12445 in forum AutoCAD Plotting
    Replies: 1
    Last Post: 2008-08-22, 07:57 PM
  4. How to change a printer setup on a layout tab
    By dfuehrer in forum AutoLISP
    Replies: 8
    Last Post: 2008-03-03, 04:34 PM
  5. Missing Page Setups in Page Setup Override
    By footprint_arch in forum AutoCAD Sheet Set Manager
    Replies: 2
    Last Post: 2005-06-15, 08:41 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
  •