TheSwamp
CAD Forums => CAD General => Topic started by: rhino on March 28, 2009, 10:37:38 PM
-
This is the PDF version of code posted here
http://www.theswamp.org/index.php?topic=27682.msg335680#msg335680 (http://www.theswamp.org/index.php?topic=27682.msg335680#msg335680)
;-------------------------------------------------------------------------------------------------------;
; Plot PDF - PDF Plot Utility © CJC aka 'RHINO' 28/03/2009 ;
;-------------------------------------------------------------------------------------------------------;
; This routine lets the user window select 'views' of page layouts in Model Space and then plots each ;
; view to a PDF file ;
;-------------------------------------------------------------------------------------------------------;
; - Limitations : Currently works for ModelSpace only ;
; - Printer driver used : DWG to PDF.pc3 ;
; - Paper Size : ISO expand A3 (420.00 x 297.00 MM) ;
; - Plot Orientation : Landscape ;
; - Plot Output Location : /ThisDrawingFileDirPath/ThisDrawingFileName-Page-#.pdf ;
;-------------------------------------------------------------------------------------------------------;
; Note- ;
; It is advisable to modify the custom properties of "DWG to PDF.pc3" plot driver to the following: ;
; - Uncheck "Open in PDF viewer when done" (does not open each plotted file in PDF viewer) ;
; - Uncheck "Include Layer Information" (depends on user requirement) ;
;-------------------------------------------------------------------------------------------------------;
(defun c:pdf (/) (c:plot_pdf))
(defun c:plot_pdf (/ usercmd userosm space dir_path dwg_name pages pdf_name cntr pg# plot *error* )
(defun *error* (msg)
(if (not
(member msg '("console break" "Function cancelled" "quit / exit abort" "" nil))
)
(princ (strcat "\nError: " msg))
)
(and usercmd (setvar "cmdecho" usercmd)
userosm (setvar "osmode" userosm)
)
(princ)
) ; end error function
; routine starts here
(setq usercmd (getvar "cmdecho")
userosm (getvar "osmode")
)
(setq space (getvar "tilemode"))
(if (= space 0)
(prompt "\nCurrently this utility does not support plots from PaperSpace!
\nYou may use the AutoCAD Publish command instead "
)
); end if modelspace = false
(if (= space 1)
(progn
(setvar "cmdecho" 0)
(setvar "osmode" 1)
(setq dir_path (getvar "dwgprefix")
dwg_name (getvar "dwgname"))
(princ "\nThis routine will plot each page layout to PDF file(s)
\nThe pdf file(s) will be saved to: /ThisDrawingFileDirPath/ThisDrawingFileName-Page-#.pdf
\nAny file with the same name will be overwritten!"
)
(initget 7)
(setq pages (getint "\nPlease Input the # of unique pages for plotting: "))
(setq cntr 1)
(while (<= cntr pages)
(setq pg# (strcat "Page-"(itoa cntr)""))
(prompt
(strcat "\nSelect each page to set plot view (Page-"(itoa cntr)") : ")
)
(command "_-view" "_window" pg# pause pause)
(setq cntr (1+ cntr))
) ;end view creation loop
(initget "Yes No")
(setq plot (getkword
(strcat "\n"(itoa (1- cntr))" page views have been created...proceed with plot? [Yes/No] <Yes>: ")))
(or plot (setq plot "Yes"))
(if (= plot "Yes")
(progn
(setq cntr 1)
(while (<= cntr pages)
(setq pg# (strcat "Page-"(itoa cntr)"")
pdf_name (strcat dir_path (substr dwg_name 1 (- (strlen dwg_name) 4)) " - " pg# ".pdf")
)
(command "._-plot"
"_yes"
""
"DWG to PDF.pc3"
"ISO expand A3 (420.00 x 297.00 MM)"
"_millimeters"
"_landscape"
"_no"
"_view"
pg#
"_fit"
"_center"
"_yes"
"monochrome.ctb"
"_yes"
"as"
pdf_name
"_No"
"_Yes"
)
(setq cntr (1+ cntr))
) ;end plot loop
(prompt
(strcat "\n"(itoa (1- cntr))" Pages successfully plotted! "))
(prompt "\nCreated by CJC aka 'RHINO'")
)
)
)
); end if modelspace = true
(*error* "")
(princ)
)
(prompt "\n plot_pdf is now available - type <pdf> to run! ")