PDF Printing with Rhino.FileIO

pdf

#1

Greetings,
I am attempting to expedite the pdf export process from Rhino but am running into a snag where I first need to run:
RhinoDoc.OpenFile(3dmPath);
doc = RhinoDoc.ActiveDoc;

On each and every file before I can export the pdf. Is it possible to utilize the Rhino.FileIO.FilePdf.Create() function without opening every single document and setting the active document?

I have the following code that returns an IList of Rhino.DocObjects.ViewInfo objects. But I cannot convert the ViewInfo object into a Rhino.Display.PageView type object needed for Rhino.FileIO.FilePdf.Create()

private static List<string> STANDARD_VIEWS = new List<string>()
            { "Top", "Bottom", "Left", "Right", "Front", "Back", "Perspective" };

        public static IList<Rhino.DocObjects.ViewInfo> GetPageViews(string path)
        {
            var layouts = new List<Rhino.DocObjects.ViewInfo>();
            
            // make sure the template file exists //
            if (System.IO.File.Exists(path) == false) { return layouts; }

            // read rhino file //
            Rhino.FileIO.File3dm file = Rhino.FileIO.File3dm.Read(path);

            // loop through files and remove standard views //
            foreach (Rhino.DocObjects.ViewInfo view in file.Views)
            {
                if (STANDARD_VIEWS.Contains(view.Name) == false)
                    layouts.Add(view);
            }

            return layouts;
        }

Is it possible to convert the ViewInfo type object into a PageView so a PDF can be printed?
This would allow pdfs from multiple files to be printed without first opening each file and would hopefully speed up the process.

Once the file is open it is possible to properly setup Rhino.Display.ViewCaptureSettings(), but I cannot seem to do it without the file being first opened as the active doc.

Has anyone been able to successfully print a pdf without opening the file?
@stevebaer ?
Thanks,


(Steve Baer) #2

I don’t think that is possible with the way our code is currently structured. I also don’t think it would necessarily speed anything up since there is an awful lot that needs to happen beyond just reading a File3dm into memory before exporting to PDF which the RhinoDoc handles.


#3

Steve,
Thanks for the quick reply. I can continue opening the files so the RhinoDoc can export the PDF.

The goal of the code I am writing is to read and export pdfs for multiple drawings. The way I am currently opening files is to run:

RhinoDoc.OpenFile(3dmPath);
doc = RhinoDoc.ActiveDoc;

This causes the rhino window to pop up for each new file that is opened. Ideally, I would like to create the pdfs in the background without disrupting the user. If this is not possible, I can of course continue to use RhinoDoc.OpenFile.
Thanks,