NCF参数化建筑论坛

标题: pdf输出脚本 感谢Sanghoon Yoon [打印本页]

作者: panhao1    时间: 2010-4-5 16:52
标题: pdf输出脚本 感谢Sanghoon Yoon
上网不小心看到的可以批量打印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


作者: casshern    时间: 2010-4-6 09:57
可惜我自己没打印机~~~~~~不过都支持一个~
作者: marcowoo    时间: 2010-4-17 23:16
不用照度实在太好了
作者: qiqiyunyan    时间: 2010-5-19 23:49
什么意思?
作者: crowwind    时间: 2010-6-17 16:47
这个工作里很方便。。。收藏了。。。
作者: 3972602    时间: 2010-7-10 10:48
不错不错 O(∩_∩)O谢谢
作者: 最牛的粽子    时间: 2010-12-15 16:17
很赞。。。学习学习
作者: ninesuns    时间: 2011-12-6 16:36
不粗不错
。。。。
作者: 月之眼    时间: 2013-10-15 23:22
发现这个好宝贝耶,,
作者: 马甲不能少    时间: 2014-2-12 11:28
谢谢分享。
作者: Checker    时间: 2020-2-16 16:33
棒棒的,赞一个。




欢迎光临 NCF参数化建筑论坛 (http://ncf-china.com/) Powered by Discuz! X3.2