这是一个开始,这是最新的版本将做你想要的它绘制一个范围,这样你可以做布局1或2-3等。你需要单独下载Ghostscript,因为它将pdf的组合成1。
- ;Plots layouts by range
- ; By Alan H Feb 2014
- (defun AH:pltlays ( / val1 val2 plotnames dwgname lendwg pdfname lay numlay numend dwgpre)
- (SETVAR "PDMODE" 0)
- (setvar "plottransparencyoverride" 2)
- (setvar "fillmode" 1)
- (setvar "textfill" 1)
- (setq plotnames '())
- ; check that pdf directory exists
- (setq dwgpre (strcat (getvar "dwgprefix") "\pdf"))
- (if (= (vl-file-directory-p dwgpre) nil)
- (vl-mkdir dwgpre)
- )
- (SETQ LAYOUTS (vla-get-Layouts (vla-get-activedocument (vlax-get-acad-object))))
- (SETQ COUNT (- (VLA-GET-COUNT LAYOUTS) 1))
- (if (not AH:getval2) (load "getvals3"))
- (ah:getval2 "Enter start tab number" 6 4 "1" "Enter end tab number" 6 4 (RTOS COUNT 2 0))
- (setq numlay (ATOI val1))
- (setq numend (ATOI val2))
- (setq len (+ (- numend numlay) 1))
- (setq dwgname (GETVAR "dwgname"))
- (setq lendwg (strlen dwgname))
- (setq dwgname (substr dwgname 1 (- lendwg 4)))
- (repeat len
- (vlax-for lay LAYOUTS
- (if (= numlay (vla-get-taborder lay))
- (setvar "ctab" (vla-get-name lay))
- ) ; if
- (setq pdfname (strcat dwgpre "\" dwgname "-" (getvar "ctab") ".pdf" ))
- ) ; for
- (setvar "textfill" 1)
- (setvar "fillmode" 1)
- (setvar "PLOTTRANSPARENCYOVERRIDE" 2)
- (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 numlay (+ numlay 1))
- (setq plotnames (cons pdfname plotnames))
- ) ; end repeat
- (setq trgfile (strcat (getvar "dwgprefix") "pdf\" dwgname "-D" val1 "-D" val2 ".pdf"))
- (setq plotnames (reverse plotnames))
- (IF (= (length plotnames) 1)
- (princ)
- (progn
- (if (not combinepdf)(load "mergepdfs"))
- (combinepdf gsExe plotnames trgFile )
- )
- )
- ) ; defun
- (AH:pltlays)
- (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 "" "") """
- )
- )
- )
还有这个
|