Hi
It try to script in python a PDF output from the current view to a predefined map and file name but I doesn’t get to the result I like.
import rhinoscriptsyntax as rs
def PrintCurrentView():
doc=rs.DocumentName()
printer='RhinoPDF'
dir="C:\\pdf_output\\"
Name='test.pdf'
cmd='-_Print Setup Margins TopMargin=5 BottomMargin=5 LeftMargin=5 RightMargin=5 _Enter '
cmd+='Destination '
cmd+='OutputColor PrintColor '
cmd+='Pagesize 297.0 210.0 '
cmd+='OutputType=Raster _Enter '
cmd+='View ViewportArea=Viewport _Enter '
cmd+='Visibility Footer '+doc+' _Enter '
#cmd+="_Enter _GO "+dir+Name+' '
cmd+='_Enter Preview '
rs.Command(cmd)
return
if name ==“main ”:
PrintCurrentView()
I like to use the Commented row to predefine the file location and name but it doesn’t work.
Or is the another way to print the current view as and PDF to a predefined map and name?
pascal
(Pascal Golay)
August 30, 2019, 6:36pm
2
Hello - take a look here:
I’m excited to let you know about a new feature that just showed up in the latest V6 WIP (Jan. 25th build).
Rhino 6 writes PDF files without the need of a printer driver.
This feature is currently only available in File->Save As… I will be integrating this into the Print command in the future. Here are some of the key new features.
No printer driver required
As I already mentioned, this feature is independent of any 3rd party printer driver. You shouldn’t have to try and figure out which pri…
There is an example script in that thread as well.
-Pascal
Hi Pascal
It tried this option but where can i change the display settings to raster format.
The pdf is in vector format but i like to have the view capture in raster format. (for the shade display mode)
Is there also an option available to print a header or footer or do I have to script the text to my view camera plane and show it ? (or should i have to create a layout page to show the result)
Below the script I used.
import Rhino
import scriptcontext as sc
import System.Drawing
#import rhinoscriptsyntax as rs
def createSinglePDF(view):
pdf = Rhino.FileIO.FilePdf.Create()
dpi = 300
size = System.Drawing.Size(11*dpi,8.5*dpi)
settings = Rhino.Display.ViewCaptureSettings(view, size, dpi)
pdf.AddPage(settings)
filename = 'c:/pdf_output/'+'ViewCaprture'+'.pdf'
pdf.Write(filename)
Views=sc.doc.Views
v=sc.doc.Views.ActiveView
createSinglePDF(v)
Hi,
I try to get the pdf working but I struggle with the pdf.DrawBitmap row.
I got and reply message: Index was out of range.
How can I fix this?
import Rhino
import scriptcontext as sc
import System.Drawing
def createSinglePDF(view):
pdf = Rhino.FileIO.FilePdf.Create()
dpi = 300
size = System.Drawing.Size(11*dpi,8.5*dpi)
settings = Rhino.Display.ViewCaptureSettings(view, size, dpi)
settings.OutputColor = Rhino.Display.ViewCaptureSettings.ColorMode.DisplayColor
capture = Rhino.Display.ViewCapture.CaptureToBitmap(settings)
pdf.AddPage(settings)
pdf.DrawBitmap(0, capture, 0, 0, 11*dpi, 8.5*dpi, 0)
filename = 'c:/pdf_output/'+'ViewCapture'+'.pdf'
pdf.Write(filename)
if __name__=="__main__":
Views=sc.doc.Views
v=sc.doc.Views.ActiveView
createSinglePDF(v)