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 )
            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.

1 Like

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?