Batch export layouts as PDFs

I’m trying to export a set of layouts as PDFs, and the best way I have found to do this is invoking the Print command in a loop:

        var detailsToPrint = doc.Views.GetPageViews();
        foreach ( var view in detailsToPrint )
        {
            view.SetPageAsActive();
            RhinoApp.RunScript(String.Format("-Print "), false);
            // How to name the file so we don't get stuck here?
        }

…but this stalls at the point where the print-to-PDF dialog asks for a destination filename, and I haven’t been able to figure out how to give it one.

Other posts suggest saving the document once manually first to get a default filename, but that didn’t seem to work (it’s still blank in the dialog after saving) and I’d like to find a way to do this without needing to set it up manually beforehand, as I’m developing a plugin.

Update: I was able to get around this by using SendKeys in a worker thread to send the dialog the filename as simulated keyboard input. Gross but works.

Hi Drew,
As you’ve already discovered, the workflow for automatically generating PDFs in V5 is pretty darn painful.

If you are willing to try the V6 WIP, you should be able to get away with a script that looks like the one I wrote in this post.

2 Likes

Hi Steve,

It is the best solution for batching pdf I ever found. Thanks a lot!

One question to make the process even more autometic. After runing the script, there will be a window pumps up. Is there a way to simulate “_Enter”, so I don’t need to press the “Okay” buttom? I have tried rs.commond("_Enter"), pynput (gives me error saying it is not for ironPython). Didn’t find a solution…

I would recommend using the approach that I outline in the referenced post above.

Hey Steve,

A further question on this topic. Is there a way to set up “Raster”/“Vector” control in python?

Can I second this. I am trying to use rhino as my sole architectural software, and I need to batch print vector. Is there a work around or something ? As all exported pdfs in vector coming out wireframe. Note I am using it on linked active models.

What version of Rhino are you using? @lukehickmandesign

Hi there using rhino 7. I have 8 but don’t want to convert projects to it yet until visual arq comes out of beta.

1 Like

Understood, sorry I only have R8 now so I don’t have a way to troubleshoot R7, hopefully another user can assist you!