乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 22|回复: 2

[编程交流] 批处理PDF打印lisp

[复制链接]

9

主题

23

帖子

14

银币

初来乍到

Rank: 1

铜币
45
发表于 2022-7-5 16:25:44 | 显示全部楼层 |阅读模式
你好
 
我有数百个DWG我需要pdf,有一个LISP可以批量pdf他们?
 
非常感谢!
回复

使用道具 举报

2

主题

261

帖子

20

银币

初来乍到

Rank: 1

铜币
8
发表于 2022-7-5 17:07:36 | 显示全部楼层
命令
_发布
还是模型空间里什么都有?
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 17:40:56 | 显示全部楼层
如果在布局中,可以编写脚本并执行数百个其他代码示例,如cadtutor中的示例。其中最新的一个绘制每个布局图纸,但随后自动合并为1个pdf。你需要一个额外的软件,但它是免费的。
 
剧本
  1. Open dwg1 (load "plotpdfall") close N
  2. Open dwg2 (load "plotpdfall") close N
  3. Open dwg2 (load "plotpdfall") close N

 
  1. ; plotpdf ver 2 with filename and directory as output oct 2011
  2. ; By Alan
  3. (defun AH:pltpdfs ( / len)
  4. (PROMPT ".....PRINTING DRAWING TO pdf's....")
  5. (setvar "cmddia" 0)
  6. (setvar "filedia" 0)
  7. (setq plotabs nil) ; in case run before
  8. (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  9. (vlax-for lay (vla-get-Layouts doc)
  10. (setq plotabs (cons (vla-get-name lay) plotabs))
  11. )
  12. (setq dwgname (GETVAR "dwgname"))
  13. (setq len (strlen dwgname))
  14. (setq dwgname (substr dwgname 1 (- len 4)))
  15. (setq plottablist (acad_strlsort plotabs))
  16. (setq len (length plottablist))
  17. (setq x 0)
  18. (repeat len
  19. (setq name (nth x plottablist))
  20. (princ name)
  21. (setq pdfname (strcat (getvar "dwgprefix") "pdf\" dwgname "-" name))
  22. ;(setq pdfname (strcat (getvar "dwgprefix") dwgname "-" name))
  23. (if (/= name "Model")
  24.    (progn
  25.    (setvar "ctab" name)
  26.    (setvar "textfill" 1)
  27. (setvar "fillmode" 1)
  28.     (COMMAND "-PLOT"  "Y"  "" "dwg to Pdf"
  29.        "Iso full bleed A3 (420.00 x 297.00 MM)" "m" "LANDSCAPE"  "N"   "W"  "-6,-6" "807,560" "1=2"  "C"
  30.        "y" "Designlasercolour.ctb" "Y" "n" "n" "n" pdfName "N" "y"      )
  31.    )
  32. )
  33. (setq x (+ x 1))
  34. (setq plotnames (cons pdfname plotnames))
  35. ) ; end repeat
  36. (setq trgfile (strcat (getvar "dwgprefix") "pdf\" dwgname "-D" val1 "-D" val2 ".pdf"))
  37. ) ; defun
  38. (setq plotnames (reverse plotnames))
  39. (AH:pltpdfs)
  40. (if (not combinepdf)(load "mergepdfs"))
  41. (combinepdf gsExe plotnames trgFile )
  42. (setvar "plottransparencyoverride" 1)
  43. (setvar "cmddia" 1)
  44. (setvar "filedia" 1)
  45. (princ)

 
  1. ;MergePdfs
  2. ;Merges multiple pdf (or eps) files into one
  3. ;Requires the installatoion of Ghostscript
  4. ; make a batch file ?
  5. ;gs -sDEVICE=pdfwrite \
  6. ;    -dNOPAUSE -dBATCH -dSAFER \
  7. ;    -sOutputFile=combined.pdf \
  8. ;    first.pdf \
  9. ;    second.pdf \
  10. ;    third.pdf [...]
  11. ;Ghostscript ([url]http://www.ghostscript.com/[/url]) can be used to combine PDFs.
  12. ; Something like this should work: by Roy_043
  13. (defun KGA_String_Join (strLst delim)
  14. (if strLst
  15. (apply
  16. 'strcat
  17. (cons
  18. (car strLst)
  19. (mapcar '(lambda (a) (strcat delim a)) (cdr strLst))
  20. )
  21. )
  22. ""
  23. )
  24. )
  25. ; (CombinePdf
  26. (setq gsexe "C:\\Program Files\\gs\\gs9.19\\bin\\gswin64c.exe")
  27. ; (setq srcFilelst  '("D:\\Tmp\\A.pdf" "D:\\Tmp\\B.pdf"))
  28. ; (setq trgfile "C:\\Acadtemp\\Total.pdf")
  29. ; )
  30. ; Note: Existing trgFile will be overwritten.
  31. (defun CombinePdf (gsExe srcFileLst trgFile)
  32. (startapp
  33. (strcat
  34. gsExe " "
  35. "-sDEVICE=pdfwrite -dBATCH -dNOPAUSE -dQUIET  "
  36. "-sOutputFile="" trgFile "" "
  37. """ (KGA_String_Join srcFileLst "" "") """
  38. )
  39. )
  40. )
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-8-20 21:27 , Processed in 0.999992 second(s), 59 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表