Hi @aimo - see this thread for syntax formatting:
Hi Lando,
FYI:
I made a type for the inch conversion. should be 25.4 and not 24.5
-Willem
Great!
Anyone able to include a way of choosing where the pdfs are saved to? I think BrowseForFolder is the command for RhinoPython
Thanks!
bumping this up
Might be a bit late:
If you want the same folder for all the files:
import Rhino
import scriptcontext as sc
from scriptcontext import doc
import System.Drawing
import rhinoscriptsyntax as rs
def createSinglePDF(view,folder):
pdf = Rhino.FileIO.FilePdf.Create()
dpi = 300
inch = 25.4
width = (view.PageWidth)/inch
height = (view.PageHeight)/inch
size = System.Drawing.Size(width*dpi,height*dpi)
settings = Rhino.Display.ViewCaptureSettings(view, size, dpi)
pdf.AddPage(settings)
filename = folder+'/'+view.PageName+'.pdf'
pdf.Write(filename)
for i in sc.doc.Views:
folder = rs.BrowseForFolder("C:\\Program Files\\" )
if folder:
if type(i) is Rhino.Display.RhinoPageView:
createSinglePDF(i,folder)
Thanks for having another look at this!
I seem to get multiple prompts to browseforfolder - any way of having only to do it only once?
Here’s a tweaked version
import Rhino
import scriptcontext as sc
from scriptcontext import doc
import System.Drawing
import rhinoscriptsyntax as rs
def createSinglePDF(view, folder):
pdf = Rhino.FileIO.FilePdf.Create()
dpi = 300
inch = 25.4
width = (view.PageWidth)/inch
height = (view.PageHeight)/inch
size = System.Drawing.Size(width*dpi,height*dpi)
settings = Rhino.Display.ViewCaptureSettings(view, size, dpi)
pdf.AddPage(settings)
filename = folder+'/'+view.PageName+'.pdf'
pdf.Write(filename)
folder = rs.BrowseForFolder("C:\\Program Files\\" )
if folder:
for i in sc.doc.Views:
if type(i) is Rhino.Display.RhinoPageView:
createSinglePDF(i,folder)
Seems to works as intended, thanks Steve, and Chris too!
Hey there! I tried this script on my file, and I struggle with text and dimensions not being exported properly (only the background mask). Have you guys ever experienced that? Any way how to tackle with that? @stevebaer?
Cheers, Petr
Page 2.pdf (459.3 KB)
Are you testing on Windows or Mac? Do you get the expected results if you File->Export to PDF?
Ah yeah, on mac. PDF exporting from layouts works just fine, but is there any difference when export to PDF by File>Export to PDF?
File->Export to PDF on Mac is different than Print to PDF on Mac. The file export technique uses our custom Rhino PDF writer which is also what the above script would be using. That’s why I’m asking specifically about File->Export
Aaah, I see. Well, two things here:
- I got crash crash while exporting using this method (report already sent)
- The preview of the pdf was sort of wrong from what I intended to export to PDF. (An odd scale and page size…?)
See the file and print screen
But I cannot confirm or disprove because of the crash…
pdf batch.3dm (3.2 MB)
edit: I have just tried on R7, where I dont get the crash. Yet, the dimensions and text is missing as well and I cant make the layout print correctly in terms of the page, margins and scale…I don’t know wether I am missing some settings, but it looks pretty odd., see the PDF
pdf batch2.pdf (14.4 KB)
@Trav is this the PDF bug that you have been working on lately?
Yes, I have been resolving several PDF on Mac issues over the past week. This was one of them. There’s a commit merging right now that fixes this scale issue as a matter of fact.
@petumatr this ticket should address your issue. If not feel free to let me know.
https://mcneel.myjetbrains.com/youtrack/issue/RH-58099
Hi @Trav,
Do you have any idea why the PDF exporter it does not print text and dimensions? (pictures above) I read through the youtrack and it is not part of it, so I guess it must be something else going on…
@petumatr the annotations issue is certainly different from the preview scaling. I am going to take a look and see if I can spot what’s happening.
Note, this post is listed as “Rhino for Windows” but I think the thread has dovetailed off into Mac specific issues.
Damn, you are right…sorry for that! My “biplatformal” brain struggles at times. But I guess it would be pointless to start new thread, or?