NCF参数化建筑论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 16294|回复: 10

[工作记录] pdf输出脚本 感谢Sanghoon Yoon

[复制链接]
发表于 2010-4-5 16:52:13 | 显示全部楼层 |阅读模式
上网不小心看到的可以批量打印pdf的脚本

注意 是打印pdf 如果你没有安装能输出pdf的插件 就会有"No layout pages!"

http://www.bullzip.com/products/pdf/info.php可以下载输出pdf的东东


Option Explicit
'2009.2.15
'Script by Sanghoon Yoon @ +plastic(韩国人?)
'http://www.byRhino3d.com | http://www.rhinos.co.kr | http://sac3.blogspot.com
[email=]'sac3yoon@gmail.com[/email]
'This script let Rhino to print all layout pages as pdf files through Bullzip pdf printer.
'Download Bullzip pdf printer @ http://www.bullzip.com/products/pdf/info.php

call PrintLayoutAsPDF
Sub PrintLayoutAsPDF
Dim strSS
strSS = Rhino.GetString ("File option" , "As_one_Pdf", Array ("As_one_Pdf", "As_each_Pdf") )
If IsNull(strSS) Then Exit Sub
Select Case strSS
  Case "As_one_Pdf"
   SaveAsOnePdf
  Case "As_each_Pdf"
   SaveAsEachPdf
End Select
End Sub

Sub SaveAsEachPdf()
Dim strFile,strFolder, arrViews,fileName, strM
strM=""
strFolder = Rhino.BrowseForFolder
arrViews = Rhino.ViewNames (True ,1)
If IsNull(arrViews) Then Rhino.Print "No layout pages!" : Exit Sub
For Each fileName In arrViews
  Rhino.CurrentView fileName
  strFile=strFolder&fileName&".pdf"
  BatchPrint strFile,strM
  Rhino.Print strFile&" was created."
Next
End Sub

Sub SaveAsOnePdf()
Dim strFile,strFolder, arrViews,fileName
strFile= Rhino.SaveFileName ("Save as pdf" ,"pdf files (*.pdf)|*.pdf||" , "" , ,"pdf")
arrViews = Rhino.ViewNames (True ,1)
If IsNull(arrViews) Then Rhino.Print "No layout pages!" : Exit Sub
For Each fileName In arrViews
  Rhino.CurrentView fileName
  BatchPrint strFile,strFile
Next
Rhino.Print strFile&" was created."
End Sub

Function BatchPrint(strFile,strM)
Const PDF_PRINTERNAME = "Bullzip PDF Printer"
Const PRINTER_PROGID = "Bullzip.PDFPrinterSettings"
Dim prtidx, obj
'Configure the PDF print job
Set obj = CreateObject(PRINTER_PROGID)
obj.SetValue "mergefile",strM
obj.SetValue "mergeposition","bottom"
obj.SetValue "Output", strFile
obj.SetValue "ConfirmOverwrite", "no"
obj.SetValue "ShowSaveAS", "never"
obj.SetValue "ShowSettings", "never"
obj.SetValue "ShowPDF", "no"
obj.SetValue "RememberLastFileName", "no"
obj.SetValue "RememberLastFolderName", "no"
obj.WriteSettings True

Rhino.Command "-print go ",False
'Wait for runonce settings file to disappear
Dim runonce, fso
runonce = obj.GetSettingsFileName(True)
Set fso = CreateObject("Scripting.FileSystemObject")
While fso.FileExists(runonce)=True
  Sleep 100
Wend
End Function

评分

参与人数 1照度 +30 收起 理由
skywoolf + 30

查看全部评分

发表于 2020-2-16 16:33:31 | 显示全部楼层
棒棒的,赞一个。
发表于 2010-4-6 09:57:40 | 显示全部楼层
可惜我自己没打印机~~~~~~不过都支持一个~
发表于 2010-4-17 23:16:31 | 显示全部楼层
不用照度实在太好了
发表于 2010-5-19 23:49:37 | 显示全部楼层
什么意思?
发表于 2010-6-17 16:47:36 | 显示全部楼层
这个工作里很方便。。。收藏了。。。
发表于 2010-7-10 10:48:34 | 显示全部楼层
不错不错 O(∩_∩)O谢谢
发表于 2010-12-15 16:17:48 | 显示全部楼层
很赞。。。学习学习
发表于 2011-12-6 16:36:09 | 显示全部楼层
不粗不错
。。。。
发表于 2013-10-15 23:22:19 | 显示全部楼层
发现这个好宝贝耶,,
发表于 2014-2-12 11:28:22 | 显示全部楼层
谢谢分享。

小黑屋|手机版|NCF参数化建筑论坛 ( 浙ICP备2020044100号-2 )    辽公网安备21021102000973号

GMT+8, 2024-4-16 23:08 , Processed in 0.061059 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表