Hello everybody,
We export a huge number of PDF drawings from AutoCAD layouts. Every PDF must be named according to a name of drawing. Function EXPORTPDF does not work that fine, because a name of each PDF is wrong (program automatically adds a name of whole AutoCAD file).
So I tried to create a LISP that could plot every each of layout into PDF format. It works fine, but I am having trouble with ADOBE CREATOR input. I am trying to find out how to input a location for a PDF file and also a name of PDF (must be the same as the name of every layout). Right now, I have to specify it for every layout, which is not good for automatization. 🙂
; PrintAll.LSP ; Routine to print all Layouts in a drawing (defun C:PrintAll ( / layouts num) (setq layouts (layoutlist)) ; list all paperspace layouts in the drawing (setq num 0) ; zero counter (repeat (length layouts) ; Repeats the plot command on all layouts (command "._PLOT" "YES" ; Detailed plot configuration? Yes/<No>: (nth num layouts) ; Enter a layout name or [?] <Layout1>: "Adobe PDF" ; Enter an output device name or [?] <Default>: "A1" ; Enter paper size or [?] <A3>: "Millimeters" ; Enter paper units Inches/<Millimeters>: "Landscape" ; Enter drawing orientation Portrait/<Landscape>: "No" ; Plot upside down? Yes/<No>: "Layout" ; Enter plot area Display/<Extents>/Layout/View/Window: "1:1" ; Enter plot scale (Plotted millimeters = Drawing Units) or Fit <1:2>: "-0.17,-1.17" ; Enter plot offset (x,y) or <Center>: "Yes" ; Plot with plot styles? Yes/<No>: "Rozvadec_moskva.ctb" ; Enter plot style table name or [?] (enter . for none) <CCL-BW.ctb>: "Yes" ; Plot with lineweights? <Yes>/No: "Yes" ; Scale lineweights with plot scale? Yes/<No>: "Yes" ; Plot paper space last? Yes/<No>: "No" ; Remove hidden lines? Yes/<No>: "No" ; Write the plot to a file? Yes/<No>: "No" ; Save changes to page setup? Yes/<No>: "Yes" ;Proceed with plot? <Yes>/No: ) (setq num (1+ num)) ; Increment counter ) ; end repeat ) ; end function
I appreciate your help! And sorry for my English.
Pavel
P.S.: Btw., I was wondering, that would be also fine to have a lisp that would rename all layouts according to blocks in tittleblok. Have you ever seen a routine for a similar problem?
Why not use the Batch Plot utility?
Maybe this will help.
Pavel,
I don't have in this PC a "Adobe PDF" printer, I changed the command, the printer, the paper size and the ctb, for testing.
Tests the code and see if it is what you need.
(defun C:test (/ layouts num) (setq layouts (layoutlist)); list all paperspace layouts in the drawing (setq num 0); zero counter (repeat (length layouts); Repeats the plot command on all layouts (command ".-PLOT" "Y" ;; Detailed plot configuration? [Yes/No] <No>: y (nth num layouts) ;;Enter a layout name or [?] <Test_001>: "DWG To PDF.pc3" ;;Enter an output device name or [?] <DWG To PDF.pc3>: "ISO A3 (297.00 x 420.00 MM)" ;;Enter paper size or [?] <ISO A3 (297.00 x 420.00 MM)>: "Millimeters" ;;Enter paper units [Inches/Millimeters] <Millimeters>: "Landscape" ;;Enter drawing orientation [Portrait/Landscape] <Landscape>: "No" ;;Plot upside down? [Yes/No] <No>: "Layout" ;;Enter plot area [Display/Extents/Layout/View/Window] <Layout>: "1:1" ;;Enter plot scale (Plotted Millimeters=Drawing Units) or [Fit] <1:1>: "-0.17,-1.17" ;;Enter plot offset (x,y) <0.00,0.00>: "Yes" ;;Plot with plot styles? [Yes/No] <Yes>: "acad.ctb" ;;Enter plot style table name or [?] (enter . for none) <acad.ctb>: "Yes" ;;Plot with lineweights? [Yes/No] <Yes>: "Yes" ;;Scale lineweights with plot scale? [Yes/No] <No>: y "Yes" ;;Plot paper space first? [Yes/No] <No>: "No" ;;Hide paperspace objects? [Yes/No] <No>: (strcat (getvar "DWGPREFIX") (getvar "CTAB") ".pdf") ;; the pdf file with the layout name "No" ;;Save changes to page setup [Yes/No]? <N> "Yes" ;;Proceed with plot [Yes/No] <Y>: );; end .-plot (setq num (1+ num)); Increment counter ); end repeat ); end function
hope that helps
Henrique
Thanks a lot. For a printer DWG To PDF.pc3 it works just fine. I tried to make it work for Adobe PDF, but I was not successfull. Never mind.
Thank you!
Hi Friends.
I'm developing a little lisp that it can to export all layouts to pdf, only you need to assing the plot scale and layout's number. If someone know the variables that it can to give our this date it will perfect, because only we will execute the command. I add the code, thanks
(DEFUN C:PRTOPDF()
(initget 7 "Inches Millimeters")
(setq punits (getkword "<Inches/Millimeters>: "))
(setq count (getint "<Layout's number>: "))
(setq countE 1)
(while (< countE (+ count 1))
(command "_plot" "y" (eval countE) "DWG To PDF.pc3" "ANSI full bleed A (8.50 x 11.00 Inches)" (eval punits) "Landscape" "n" "" "" "" "" "" "" "." "" "y" "n" "n" "" "y" "y")
(setq countE (+ countE 1))
)
(prin1)
)
Hi hmsilva, can you help develop this lisp, I want to plot all layouts via Printer, not pdf, I tried to change the name of device but it failed.
@HeroSy wrote:
Hi hmsilva, can you help develop this lisp, I want to plot all layouts via Printer, not pdf, I tried to change the name of device but it failed.
Hi HeroSy,
To change the code to plot to a different device, you'll need to enter at the command line the command '-plot', then 'y' and answering the prompts.
When the command finish, press F2 and copy the correct device name (.pc3), the correct paper name, and you'll neeed to follow the correct prompt sequence.
If you have difficulties in doing that, copy/paste the the command line prompts in your reply.
Hope this helps,
Henrique
John F. Uhden