Batch Export PDF

Hello Everybody

I am trying to create a script to batch export drawings as PDF files, and I’ve hit a wall. Any suggestions would be really helpful.

My goal is to automate exporting of 100+ files. I’ve looked at posts here (and a few other posts all day), but found only solutions with Layouts, using the GetPageViews() method.

page = sc.doc.Views.GetPageViews()

Here are my questions:

  1. Is there a way to automatically arrange the Layout’s Detail Window (is that how I should call it?) to cover my modelspace, similar to Set Window feature in a Print Command?

  2. I’ve been trying to use the _-Print command to set up all necessary settings. But, I end up with a pop-up window, that requires me to Manually enter the FileName as well as the location. Although, I see the prompt for entering a filename in the console, I can’t get it to work. Is it possible to override the pop-up box?

File1: 2021.01.11 - batchExportPDF.3dm (139.0 KB)
File2: 2021.01.11 - batchExportPDF.gh (3.8 KB)

def exportPDF(fileName):

    # A4 Portrait
    a4x = "210"
    a4y = "297"

    separator = "\\"
    if platform.system() == "Darwin": separator = "/"

    # Get current file directory
    activeDocPath = str(os.path.dirname(os.path.realpath(Rhino.RhinoDoc.ActiveDoc.Path)))

    # Rhino _Macro
    Rhino.RhinoApp.RunScript("_-Print Setup Destination PageSize _Enter" + a4x + " " + a4y + " Enter View ViewportArea Window " + a4x + "," + a4y + " 0,0 _Enter _Enter Go _Enter" , True)

    # Trying to get this work
    # Rhino.RhinoApp.RunScript("_-Print Setup Destination PageSize _Enter" + a4x + " " + a4y + " Enter View ViewportArea Window " + a4x + "," + a4y + " 0,0 _Enter _Enter Go _Enter" + activeDocPath + separator +  fileName + ".pdf", True)

    return

~ ~ ~ ~ ~ ~ ~ ~
Kaushik LS
Chennai, IN

I can’t help you with your export, but would like to give you a small tip.
You don’t have to manually find out what should be the path separator, just use os.sep

1 Like