Jump to content

Cycle through Layouts to Plot each one


woodman78

Recommended Posts

I am trying to create a routine that will cycle through the layouts and automatically plot each one without any interaction from the user. This is what I have to date but it isn't cycling through the layouts. Can anyone help?

 

(defun c:a3all ( / lst )
   (foreach pair (dictsearch (namedobjdict) "ACAD_LAYOUT")
       (if (= 3 (car pair))
           (setq lst (cons (cdr pair) lst))
(A3forall)
       )
   )
   (reverse lst)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Based on PageSetups from Alan J. Thompson
(defun A3Forall ()
(PlotReactorOFF)
 (if (findfile "T:/Drawing Tools/Templates/CCC2009.dwt")
   (progn
     (command "_.psetupin" (findfile "T:/Drawing Tools/Templates/CCC2009.dwt") "A3")
     (while (wcmatch (getvar "cmdnames") "*PSETUPIN*")
       (command "_yes")
     ) ;_ while
     T
   ) ;_ progn
 ) ;_ if
(command "-plot" "n" ACAD_LAYOUT "A3" "" "n" "y" "y")
(setq CCC_Sheet "A3")
(command "_zoom" "e")
 (initdia)
 (command "._plot")
(PlotReactorON)
;(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun PlotReactorON nil
 (vl-load-com)
 ;; © Lee Mac 2010

 (  (lambda ( data foo / react )
      (if (setq react
            (vl-some
              (function
                (lambda ( reactor )
                  (if (eq data (vlr-data reactor)) reactor)
                )
              )
              (cdar
                (vlr-reactors :vlr-command-reactor)
              )
            )
          )
        (if (not (vlr-added-p react))
          (vlr-add react)
        )
        (setq react
          (vlr-command-reactor data
            (list
              (cons :vlr-commandwillstart foo)
            )
          )
        )
      )
      (if (vlr-added-p react)
        (princ "\n** Reactor Activated **")
        (princ "\n** Reactor Failed to Activate **")
      )
      react
    )
   "Plot-Reactor"
   'Plot-Callback
 )

 (princ)
)

(defun PlotReactorOFF nil
 (vl-load-com)
 ;; © Lee Mac 2010

 (  (lambda ( data foo / react )
      (if (setq react
            (vl-some
              (function
                (lambda ( reactor )
                  (if (eq data (vlr-data reactor)) reactor)
                )
              )
              (cdar
                (vlr-reactors :vlr-command-reactor)
              )
            )
          )
        (if (vlr-added-p react)
          (vlr-remove react)
        )
      )
      (if (or (not react) (not (vlr-added-p react)))
        (princ "\n** Reactor Deactivated **")
        (princ "\n** Reactor Failed to Deactivate **")
      )
      react
    )
   "Plot-Reactor"
   'Plot-Callback
 )
 
 (princ)
)

(defun Plot-Callback ( reactor arguments )
 (vl-load-com)

 (if (eq (strcase (car arguments)) "PLOT")
   (LM:Popup "Warning" 64 "Gotcha!!!   Please use the NNRDO Plot tools when plotting standard layouts!!")
 )

 (princ)
)

(defun LM:Popup ( title flags msg / WSHShell result )
 ;; © Lee Mac 2010
 (setq WSHShell (vlax-create-object "WScript.Shell"))
 (setq result   (vlax-invoke WSHShell 'Popup msg 0 title flags))
 (vlax-release-object WSHShell)
 
 result
)

 

Thanks.

Link to comment
Share on other sites

Hi !

 

I have done this some times before. Here my expressions, put in your defaults and than drives the routine all layouts in drawing and sent it to Plotter xxx.

 

(defun c:Plt ( / )
 (foreach layoutname (vl-remove "Model" (layoutlist))
   (command "._layout" "set" layoutname)
   (command "_plot"
        "_y"       ; Detailed plot configuration? [Yes/No] <No>: y
        layoutname ; Enter a layout name or [?] <4111>:
        "Plt.pc3"  ; Enter an output device name or [?] <Plt.pc3>:
        "ISO A1 (594.00 x 841.00 MM)" ; Enter paper size or [?] <ISO expand A1 (594.00 x 841.00 MM)>:
        "Millimeters" ;Enter paper units [inches/Millimeters] <Inches>:
        "Landscape" ; Enter drawing orientation [Portrait/Landscape] <Landscape>:
        "No" ; Plot upside down? [Yes/No] <No>:
        "_e" ; Enter plot area [Display/Extents/Layout/View/Window] <Extents>: e
        "1000=1" ; Enter plot scale (Plotted Millimeters=Drawing Units) or [Fit] <1000=1>: 
        "_c" ; Enter plot offset (x,y) or [Center] <Center>: c
        "_y" ; Plot with plot styles? [Yes/No] <Yes>:
        "A1.ctb" ; Enter plot style table name or [?] (enter . for none) <A1.ctb>:
        "_y" ; Plot with lineweights? [Yes/No] <Yes>:
        "_n" ; Scale lineweights with plot scale? [Yes/No] <No>:
        "_n" ; Plot paper space first? [Yes/No] <No>:
        "_n" ;Hide paperspace objects? [Yes/No] <No>:
        "_y" (strcat "c:\\pdfplot\\" (substr (setq str (getvar "dwgname")) 1 (- (strlen str) 4)) "-" layoutname)  ;Write the plot to a file [Yes/No] <Y>:
        "_n" ; Save changes to page setup [Yes/No]? <N>
        "_y" ;Proceed with plot [Yes/No] <Y>:
        )
   )
 (princ "\nComplete...")
 (princ)
 )

Link to comment
Share on other sites

Here's mine:

 

(defun C:PAP (/ CURRENTTAB)
 (setq CURRENTTAB (getvar "ctab"))
 (foreach LAYOUT (layoutlist)
   (setvar "ctab" LAYOUT)
;;;;;;;;;;;;;;;;;;;;;;;;;;;
   (command "-PLOT" "YES" ""
     "MODFT1_HP5SI" "LETTER (8.5\" X 11\")"
;      "MODFT2_HP5SI" "Letter"
                    "INCHES" "LANDSCAPE"
                    "NO" "EXTENTS" "FIT" "CENTER" "YES" "Mine.CTB"
                    "YES" "NO" "NO" "NO" "NO" "NO" "YES"
    )
;;;;;;;;;;;;;;;;;;;;;;;;;;

   (setvar "ctab" CURRENTTAB)
   (princ)
 )

Edited by SLW210
Link to comment
Share on other sites

Try this one, it will ask you how many copies do you want.

 

;;; LAYOUT PRINT 18x24
(defun c:Tab ( / CURRENTTAB)
(pltnum)
 (setq CURRENTTAB (getvar "ctab"))
 (repeat xplta (foreach LAYOUT (layoutlist)
   (setvar "ctab" LAYOUT)
   (command "-plot" 
"yes" 
""
"TFC-ENGXER6204.pc3" 
"Arch C (18x24 in.)" 
"Inches"
"LANDSCAPE" 
"NO" ;PLOT UPSIDE DOWN
"EXTENTS" 
"FIT" 
"0.076012,0.00" 
"YES" ;PLOT WITH PLOTSYTLES
"MONOCHROME.CTB" 
"NO" ;PLOT WITH LINEWEIGHTS
"NO" ;SCALE LINEWEIGHTS WITH PLOT SCALE
"YES" ;PLOT PAPER SPACE LAST
"NO" ;REMOVE HIDDEN LINES
"NO" ;WRITE THE PLOT TO A FILE
"NO" ;SAVE CHANGES TO LAYOUT
"YES");PROCEED WITH PLOT
 )
)
(defun pltnum ()
(setq numplt (getint "\nEnter Number of Plots <1>: "))
(if (= numplt nil) (setq xplt 1) (setq xplt numplt))
(if (<= xplt 15) (setq xplta xplt) (setq xplta 15))
) 
(setvar "ctab" CURRENTTAB)
 (princ)
)

Link to comment
Share on other sites

BrianTFC,

It is brilliant. I have integrated your code into my code to give me the features I had with the previous one and it works very well. This is what I ended up with..

 

(defun c:AP33 ( / CURRENTTAB)
(PlotReactorOFF)
(command "_.-layer" "_LW" "0.13" "CCC_LAYOUT_Dimensions" "")
 (if (findfile "T:/Drawing Tools/Templates/CCC2009.dwt")
   (progn
     (command "_.psetupin" (findfile "T:/Drawing Tools/Templates/CCC2009.dwt") "A3")
     (while (wcmatch (getvar "cmdnames") "*PSETUPIN*")
       (command "_yes")
     ) ;_ while
     T
   ) ;_ progn
 ) ;_ if
(command "_-purge" "a" "*" "N")
(setq CCC_Sheet "A3")
(pltnum)
 (setq CURRENTTAB (getvar "ctab"))
 (repeat xplta (foreach LAYOUT (layoutlist)
   (setvar "ctab" LAYOUT)
(command "-plot" "n" "" "A3" "" "n" "y" "n")
(command "_zoom" "e")
(command "updatefield" "all" "")
(command "regenall")
(command "-plot" "n" "" "A3" "" "n" "y" "y")
 )
)
;(defun pltnum ()
;(setq numplt (getint "\nEnter Number of Plots <1>: "))
;(if (= numplt nil) (setq xplt 1) (setq xplt numplt))
;(if (<= xplt 15) (setq xplta xplt) (setq xplta 15))
 
(setvar "ctab" CURRENTTAB)
(PlotReactorON)
 (princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun pltnum ()
(setq numplt (getint "\nEnter Number of Plots <1>: "))
(if (= numplt nil) (setq xplt 1) (setq xplt numplt))
(if (<= xplt 15) (setq xplta xplt) (setq xplta 15))
) 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun PlotReactorON nil
 (vl-load-com)
 ;; © Lee Mac 2010

 (  (lambda ( data foo / react )
      (if (setq react
            (vl-some
              (function
                (lambda ( reactor )
                  (if (eq data (vlr-data reactor)) reactor)
                )
              )
              (cdar
                (vlr-reactors :vlr-command-reactor)
              )
            )
          )
        (if (not (vlr-added-p react))
          (vlr-add react)
        )
        (setq react
          (vlr-command-reactor data
            (list
              (cons :vlr-commandwillstart foo)
            )
          )
        )
      )
      (if (vlr-added-p react)
        (princ "\n** Reactor Activated **")
        (princ "\n** Reactor Failed to Activate **")
      )
      react
    )
   "Plot-Reactor"
   'Plot-Callback
 )

 (princ)
)

(defun PlotReactorOFF nil
 (vl-load-com)
 ;; © Lee Mac 2010

 (  (lambda ( data foo / react )
      (if (setq react
            (vl-some
              (function
                (lambda ( reactor )
                  (if (eq data (vlr-data reactor)) reactor)
                )
              )
              (cdar
                (vlr-reactors :vlr-command-reactor)
              )
            )
          )
        (if (vlr-added-p react)
          (vlr-remove react)
        )
      )
      (if (or (not react) (not (vlr-added-p react)))
        (princ "\n** Reactor Deactivated **")
        (princ "\n** Reactor Failed to Deactivate **")
      )
      react
    )
   "Plot-Reactor"
   'Plot-Callback
 )
 
 (princ)
)

(defun Plot-Callback ( reactor arguments )
 (vl-load-com)

 (if (eq (strcase (car arguments)) "PLOT")
   (LM:Popup "Warning" 64 "Gotcha!!!   Please use the NNRDO Plot tools when plotting standard layouts!!")
 )

 (princ)
)

(defun LM:Popup ( title flags msg / WSHShell result )
 ;; © Lee Mac 2010
 (setq WSHShell (vlax-create-object "WScript.Shell"))
 (setq result   (vlax-invoke WSHShell 'Popup msg 0 title flags))
 (vlax-release-object WSHShell)
 
 result
)

 

Thanks again BrianTFC.

Link to comment
Share on other sites

I'm Glad i could help. I've gotten alot of great help from the guru's on this site. i nice to able to pay it foward when i can. i've got a question about your routine? when you want multiple copies does it batch them first and then print out the numbers of copies after it batches it?

Link to comment
Share on other sites

They come out in sets the same as the layouts. So they are stacked in the printer as Layout01,Layout02,Layout03,Layout01,Layout02,Layout03.

This is exactly as I want it. I would generally have 3 or 4 layouts per drawing with anything up to 30 drawings so if they are sorted right out of the printer it saves me the time.

 

Thanks again.

Link to comment
Share on other sites

Woodman,

 

I modified your code to my setting and ran it, my code does the same thing as your does so why you need all of the "psetupin","plotreactoron" and "plotreactoroff"? i was hoping that it would batch the drawings after it ran through the layout tabs and then make copies of the batch instead of going through the layout tabs and then go back to the first tab and and doing it again.

Link to comment
Share on other sites

Well I have a single template that I use for all plot sizes. A combination of the psetupin and fields allow me to display the page size on the sheet and to modify the scale accordingly. I run the plot command twice because the first time it sets the page setup and then I force update all fields. Then I replot.

 

The "plotreactoron" and "plotreactoroff" I setup a long time ago now to force the guys in the office to start using the commands. They get a dialog warning if they try to bypass the custom plot command because the fields won't update and so the scale may appear incorrect on the drawings.

 

Hope this clarifies a few things.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...