如果在布局中,可以编写脚本并执行数百个其他代码示例,如cadtutor中的示例。其中最新的一个绘制每个布局图纸,但随后自动合并为1个pdf。你需要一个额外的软件,但它是免费的。
剧本
- Open dwg1 (load "plotpdfall") close N
- Open dwg2 (load "plotpdfall") close N
- Open dwg2 (load "plotpdfall") close N
- ; plotpdf ver 2 with filename and directory as output oct 2011
- ; By Alan
- (defun AH:pltpdfs ( / len)
- (PROMPT ".....PRINTING DRAWING TO pdf's....")
- (setvar "cmddia" 0)
- (setvar "filedia" 0)
- (setq plotabs nil) ; in case run before
- (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 dwgname (GETVAR "dwgname"))
- (setq len (strlen dwgname))
- (setq dwgname (substr dwgname 1 (- len 4)))
- (setq plottablist (acad_strlsort plotabs))
- (setq len (length plottablist))
- (setq x 0)
- (repeat len
- (setq name (nth x plottablist))
- (princ name)
- (setq pdfname (strcat (getvar "dwgprefix") "pdf\" dwgname "-" name))
- ;(setq pdfname (strcat (getvar "dwgprefix") dwgname "-" name))
- (if (/= name "Model")
- (progn
- (setvar "ctab" name)
- (setvar "textfill" 1)
- (setvar "fillmode" 1)
- (COMMAND "-PLOT" "Y" "" "dwg to Pdf"
- "Iso full bleed A3 (420.00 x 297.00 MM)" "m" "LANDSCAPE" "N" "W" "-6,-6" "807,560" "1=2" "C"
- "y" "Designlasercolour.ctb" "Y" "n" "n" "n" pdfName "N" "y" )
- )
- )
- (setq x (+ x 1))
- (setq plotnames (cons pdfname plotnames))
- ) ; end repeat
- (setq trgfile (strcat (getvar "dwgprefix") "pdf\" dwgname "-D" val1 "-D" val2 ".pdf"))
- ) ; defun
- (setq plotnames (reverse plotnames))
- (AH:pltpdfs)
- (if (not combinepdf)(load "mergepdfs"))
- (combinepdf gsExe plotnames trgFile )
- (setvar "plottransparencyoverride" 1)
- (setvar "cmddia" 1)
- (setvar "filedia" 1)
- (princ)
- ;MergePdfs
- ;Merges multiple pdf (or eps) files into one
- ;Requires the installatoion of Ghostscript
- ; make a batch file ?
- ;gs -sDEVICE=pdfwrite \
- ; -dNOPAUSE -dBATCH -dSAFER \
- ; -sOutputFile=combined.pdf \
- ; first.pdf \
- ; second.pdf \
- ; third.pdf [...]
- ;Ghostscript ([url]http://www.ghostscript.com/[/url]) can be used to combine PDFs.
- ; Something like this should work: by Roy_043
- (defun KGA_String_Join (strLst delim)
- (if strLst
- (apply
- 'strcat
- (cons
- (car strLst)
- (mapcar '(lambda (a) (strcat delim a)) (cdr strLst))
- )
- )
- ""
- )
- )
- ; (CombinePdf
- (setq gsexe "C:\\Program Files\\gs\\gs9.19\\bin\\gswin64c.exe")
- ; (setq srcFilelst '("D:\\Tmp\\A.pdf" "D:\\Tmp\\B.pdf"))
- ; (setq trgfile "C:\\Acadtemp\\Total.pdf")
- ; )
- ; Note: Existing trgFile will be overwritten.
- (defun CombinePdf (gsExe srcFileLst trgFile)
- (startapp
- (strcat
- gsExe " "
- "-sDEVICE=pdfwrite -dBATCH -dNOPAUSE -dQUIET "
- "-sOutputFile="" trgFile "" "
- """ (KGA_String_Join srcFileLst "" "") """
- )
- )
- )
|