Python Print Settings

Just want to preface by saying that this is my first experience with doing something like this, I’ve done some fairly extensive GH definitions so I get the logic but wrapping my head around visualizing things from text only is proving to be challenging.

I’m looking to add a little to the functionality of @stevebaer 's print all pages script:

import os
import scriptcontext as sc
import rhinoscriptsyntax as rs
from System.IO import Path, File

path = rs.DocumentPath()
filename = rs.DocumentName()
name = (os.path.splitext(filename)[0])
savename = rs.SaveFileName ("Save", "PDF files (*.pdf)|*.pdf||", path + "Shop Drawings", name)

pages = sc.doc.Views.GetPageViews()
pdf = Rhino.FileIO.FilePdf.Create()
dpi = 180

for page in pages:
    capture = Rhino.Display.ViewCaptureSettings(page, dpi)

I added the savename bit to save me browsing for a location and it’s worked out, but I’m struggling to set the ‘Destination>Output Color’ to ‘Display Color’. I’ve tried a bunch of different ways using ViewCaptureSettings.OutputColor and ColorMode and others but my lack of understanding when it comes to formatting and syntax may be preventing me from getting it to where it needs to be.

The primary purpose of this is to overcome Rhino’s inability to have print settings persist. Every print I make has to have the resolution manually changed to have an email-sized pdf output, and the ‘View and Output Scale’ has to be set to ‘All Layouts’. This script does a great job of solving both of those problems but unfortunately has introduced the other one.

As an alternative is it possible to have all objects created have their print color default to By Object rather than By Layer as it is currently? I figured that would solve it just as well, but the downside is that it won’t help me get any better at python.



What you want to do is set the colormode of the viewcapturesettings.
try this:

#my example is DisplayColor but maybe you need another
colormode =Rhino.Display.ViewCaptureSettings.ColorMode.DisplayColor 
capture.OutputColor = colormode

Im copy pasting in my phone so I hope this is enough to get you going.


1 Like

Perfect! I inserted those two lines between ‘capture =…’ and ‘pdf.addpage…’ and it works like a charm. Thanks!

1 Like