这是为了测试,似乎正在测试中工作,它需要用户修改,因为我不想进入打印机配置设置。您应该已经为大图纸设置了图纸尺寸,以及需要将其放入代码开头相应图纸标题栏列表的代码中的绘图仪。我已经将图纸设置为只适合测试,这应该是1=1。在进行手动“绘图”时,您可以通过查看所拥有的内容来手动检查,与要使用的Ctb相同。我刚刚使用了1。您可能还需要更改左下ll和右上ur窗口拾取点,这允许在绘图区域内微妙地移动图纸。pdfname和目标是用户可定义的,如果需要,我们可以进行一些更改。
我没有找到一种简单的方法来制作1个组合pdf,所以我使用Ghostscript将输出重新组合成1个pdf。如果需要此选项,请删除;从这三行中,确保在支持路径中有mergepdf。
为简单起见,最后一条规则代码期望标题栏位于左下角0,0,可以添加查找标题栏,但在这个阶段,我想看看代码是否满足您的需要,只是增加了一个复杂度。
- ;Plots layouts by range
- ; By Alan H Feb 2014
- ; chnaged to recognize title block name
- (defun AH:pltlays ( / val1 val2 plotnames dwgname lendwg pdfname lay numlay numend dwgpre lstsheet sc ll ur trgfile)
- (SETVAR "PDMODE" 0)
- (setvar "plottransparencyoverride" 2)
- (setvar "fillmode" 1)
- (setvar "textfill" 1)
- (setq plotnames '())
- ; list of parameters for sheet sizes
- ; hard coded to A3 size for testing change A3 to correct plot sheet
- (setq lstsheet (list
- ;(list "A0-HOR1350" "-6,-6" "1356,847" "your sheet size here" "your.ctb here" "1=1")
- (list "A0-HOR1350" "-6,-6" "1356,847" "Iso full bleed A3 (420.00 x 297.00 MM)" "DesignlaserCOLOUR_1.ctb" "f") ; change the f to 1=1 for full size
- (list "A1-HOR1189" "-6,-6" "1195,600" "Iso full bleed A3 (420.00 x 297.00 MM)" "DesignlaserCOLOUR_1.ctb" "f")
- (list "A2-HOR841" "-6,-6" "847,426" "Iso full bleed A3 (420.00 x 297.00 MM)" "DesignlaserCOLOUR_1.ctb" "f")
- (list "A0-HOR" "-6,-6" "1195,847" "Iso full bleed A3 (420.00 x 297.00 MM)" "DesignlaserCOLOUR_1.ctb" "f")
- (list "Da1drsht" "-6,-6" "807,560" "Iso full bleed A3 (420.00 x 297.00 MM)" "DesignlaserCOLOUR_1.ctb" "1=2") ; for additional testing
- ))
- ; all pdf output goes into a subdirectory below dwg location
- ; check that pdf directory exists
- (setq dwgpre (strcat (getvar "dwgprefix") "\pdf"))
- (if (= (vl-file-directory-p dwgpre) nil)
- (vl-mkdir dwgpre)
- )
- ; get all layouts
- (setq lays (vla-get-Layouts (vla-get-activedocument (vlax-get-acad-object))))
- ; open up the dcl for the sheet range
- (if (not AH:getval2) (load "getvals3"))
- (ah:getval2 "Enter start tab number" 6 4 "1" "Enter end tab number" 6 4 (rtos (- (vla-get-count lays) 1) 2 0))
- ; return the start and end range
- (setq numlay (ATOI val1))
- (setq numend (ATOI val2))
- (setq len (+ (- numend numlay) 1))
- ; current dwg name
- (setq dwgname (GETVAR "dwgname"))
- (setq lendwg (strlen dwgname))
- (setq dwgname (substr dwgname 1 (- lendwg 4)))
- ; go through the layout range and open to plot
- (repeat len
- (vlax-for lay lays
- (if (= numlay (vla-get-taborder lay))
- (setvar "ctab" (vla-get-name lay))
- ) ; if
- ; select title block using a small fence line
- (setq ss (ssget "f" (list (list -3 -3) (list 3 3))(list (cons 0 "Insert"))))
- (if (> 1 (sslength ss))
- (progn
- (alert "There appears to be two blocks at 0,0\n\nProgram will exit")
- (exit)
- )
- (princ)
- )
- ; title block name
- (setq bname (vla-get-name (vlax-ename->vla-object (ssname ss 0))))
- ; set all the variables that match the title block
- (foreach plotdets lstsheet
- (if (= (nth 0 plotdets) bname)
- (progn
- (setq ll (nth 1 plotdets))
- (setq ur (nth 2 plotdets))
- (setq sheetname (nth 3 plotdets))
- (setq ctb (nth 4 plotdets))
- (setq sc (nth 5 plotdets))
- )
- )
- )
- ; Pdfname for output
- (setq pdfname (strcat dwgpre "\" dwgname "-" (getvar "ctab") ".pdf" ))
- ) ; for
- ; plot
- (setvar "textfill" 1)
- (setvar "fillmode" 1)
- (COMMAND "-PLOT" "Y" "" "DWG To PDF" sheetname "m" "LANDSCAPE" "N" "W" ll ur sc "C" "y" ctb "Y" "n" "n" "n" pdfName "N" "y" )
- ; goto next layout
- (setq numlay (+ numlay 1))
- (setq plotnames (cons pdfname plotnames))
- ) ; end repeat
- (setq plotnames (reverse plotnames))
- ; the next 3 lines calls Ghostscript to combine the individual pdfs into 1 pdf
- ; needs Ghostscript to be downloaded seperately www.ghostscript.com
- ;(setq trgfile (strcat (getvar "dwgprefix") "pdf\" dwgname "-D" val1 "-D" val2 ".pdf"))
- ;(if (not combinepdf)(load "mergepdfs"))
- ;(combinepdf gsExe plotnames trgFile )
- ) ; defun
- (AH:pltlays)
- (setvar "plottransparencyoverride" 1)
- (princ)
合并PDF。lsp
GETVALS3.lsp |