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.

(Steve Baer) #3

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.