I tried to incorporate a pause into the plot command but after the first plot it just stopped.



Registered forum members do not see this ad.
Ok, here is where I am at the moment. I have had to abandon using the "dwg to pdf" and it is for asthetic reasons more than anything. The lisp worked alright but see the image and the poor quality of the pdf using the "dwg to pdf".
rps20120518_094748_902.jpg
To be honest it wouldn't cut it around our place. We have been using "Cutepdf" for many years now with very good results. So I am back to this for batch plotting pdf's.
The problem I am having with this is that it runs fine and launches the curepdf file save as window. And the autocad plot window reloads. I click "save" on the cutepdf window, which is not a big issue. Then I click plot on the autocad window but it plots the same layout. It can run like that for 5 or 6 times and eventually change the layout.Code:;Based on PageSetups from Alan J. Thompson (defun c:A3_all_pdf () (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") (princ x)(setq x (+ x 1)) ) ;_ while T ) ;_ progn ) ;_ if (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vlax-for lay (vla-get-Layouts doc) (setq plotabs (cons (vla-get-name lay) plotabs)) ) (setq plottablist (acad_strlsort plotabs)) (setq len (length plottablist)) (setq x 0) (repeat len (setq name (nth x plottablist)) (princ name) (if (/= name "Model") (progn (setvar "ctab" name) (command "-plot" "n" "" "A3-pdf" "" "n" "y" "y") (command "_-purge" "a" "*" "N") (setq CCC_Sheet "A3") (command "updatefield" "all" "") (command "regenall") (command "_zoom" "e") (initdia) (command "._plot") ) ;<- IF ) ;<- PROGN ;(princ) (setq x (1+ x)) ) (PlotReactorON) ) ;<- DEFUN ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (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 )
This is the cutepdf save window
plot pdf.jpg
I would appreciate it if anyone had any ideas how to get around this. Thanks.



I tried to incorporate a pause into the plot command but after the first plot it just stopped.
Use (layoutlist) for layout names
instead of repeat use foreach
(foreach name (layoutlist) '<-- this wil eliminate the variables name and x
.....
)
and DO NOT forget to localize plotabs variable.
This line:
If you dont localize the variable the list will continue to "grow" the next time you use the commandCode:(vlax-for lay (vla-get-Layouts doc) (setq plotabs (cons (vla-get-name lay) plotabs)) )
That is why i suggested on your previous post to use (layoutlist) as this will give you a list without "Model" and its already sorted and no need to assign to a variable.Code:(defun c:A3_all_pdf ( / PlotReactorOFF doc lay plotabs plottablist ....)
HTH
Cheers
BTW: whats the use of CCC_Sheet variable?



Thanks pBe, I tried to incorporate your comments and this is what I have but what I have doesn't run. I have been looking and can't quite get my head around what I need to remove or keep.
What have I missed?Code:;Based on PageSetups from Alan J. Thompson (defun c:A3_all_pdf ( / PlotReactorOFF doc lay plotabs plottablist name) (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") (princ x)(setq x (+ x 1)) ) ;_ while T ) ;_ progn ) ;_ if (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vlax-for lay (vla-get-Layouts doc) (setq plotabs (cons (vla-get-name lay) plotabs)) ) (setq plottablist (acad_strlsort plotabs)) (setq len (length plottablist)) ;(setq x 0) (foreach name (layoutlist)) ;(setq name (nth x plottablist)) (princ name) (if (/= name "Model") (progn (setvar "ctab" name) (command "-plot" "n" "" "A3-pdf" "" "n" "y" "y") (command "_-purge" "a" "*" "N") (command "updatefield" "all" "") (command "regenall") (command "_zoom" "e") (initdia) (command "._plot") ) ;<- IF ) ;<- PROGN ;(princ) ; (setq x (1+ x)) ) (PlotReactorON) ) ;<- DEFUN
CCC_Sheet was an overhang from an earlier version and can be removed.
Still not sure what your code is all about but the obvious reason is this.....
Still.. not sureCode:(foreach name (layoutlist));<----- loose this one
Code:(defun c:A3_all_pdf ( / PlotReactorOFF tmptfile PlotReactorON) (PlotReactorOFF) (setvar 'Expert 5) (if (setq tmptfile (findfile "T:/Drawing Tools/Templates/CCC2009.dwt")) (progn (command "_.psetupin" tmptfile "A3") (foreach name (layoutlist) (setvar "ctab" name) (command "-plot" "n" "" "A3-pdf" "" "n" "y" "y") (command "_-purge" "a" "*" "N") (command "updatefield" "all" "") (command "regenall") (command "_zoom" "e") (initdia) (command "._plot") ) ) ) (PlotReactorON) (princ) )



I get this error when I run your revised code pBe:
The code is supposed to plot all layouts to pdf using cutepdf printer. The problem was it was plotting the same layout over and over again.Code:; error: no function definition: PLOTREACTOROFF
(PlotReactorOFF) and (PlotReactorON) came from your post Woodman78



They are LeeMac's subroutines. I just removed them from the variable list and it works fine now. Thanks pBe.
Registered forum members do not see this ad.
Glad it helps Woodman78. keep on coding
Cheers
Bookmarks