Print model space to pdf

I am trying to print a model space to a pdf by using rs.Command.
For some reason the following command does not do anything: _-Print _Go
Is this a bug? Does this mean that Rhino 6 does not allow to use the suppress dialog box Print command?

The PDF dialog cannot be suppressed through macros. I believe that dialog box is technically a different program, so you can’t interact with it through rhino. There are some options to make this work though.

First, you can now print to PDF through rhinocommon, though its options are limited and it only prints in wireframe view with sharp edges on everything: https://developer.rhino3d.com/api/RhinoCommon/html/Methods_T_Rhino_FileIO_FilePdf.htm

I’ve exposed this though my Sasquatch Plugin to grasshopper with an extra option of embedding raster views if you are using grasshopper. Disclaimer though - I haven’t actually used this component in my own workflow yet, so I don’t know what kind of issues might come up yet. I’ve been looking for a way to hack in rounded edges through other PDF libraries before I use it myself, but I’ve had no success yet:

Second, you can use an external pdf library to draw to a file. Something like iTextSharp for .NET development. This should work, but the conversion from 3D nurbs to 2D bezier curves that the PDF writers use would take some effort to write.

Last, and something that I have done before in c#, is to write your code so that it hijacks the print to pdf dialog after you run the macro to enter in the file name and hit print. This requires the dialog hijacking code to run on a thread parallel to the code running the macro and watch for the print dialog to pop up, which is a little bit complicated to write. The dialog hijacking also not a stable solution and only something you should be doing as a last resort. I don’t have the code on me at the moment. If I can find it I’ll share.

2 Likes

Hi @sc_o,

Thank you for the detailed reply!
For some reason your Sasquatch Utilities plugin does not appear in the separate tab in the Grasshopper.
I unblocked both the “itextsharp.dll” and “Sasquatch.gha” and put them into the “Components Folder” (C:\Users*Username*\AppData\Roaming\Grasshopper\Libraries), restarted Rhino, but still the “Sasquatch” tab does not appear in Grasshopper.
Have you had this kind of case?
I have Rhino 6 SR11.

@djordje Hmm… this is the first I’ve heard of that happening. There should definitely be a Sasquatch Tab. That release of Sasquatch was written on SR12 and I’m not sure if it is backward compatible to SR11 though. I don’t have a machine running an older version to test it on myself right now.

If you can, try updating and let me know if it still doesn’t work.

The next Sasquatch release will be using SDK commands introduced in SR13 which I know won’t be backward compatible with earlier service releases. I’ll add a disclaimer in the future.

1 Like

Hi @sc_o,
I just updated to Rhino SR13, and your plugin works with no issues.
Thank you for the help!

Thanks for letting me know! I’ve added the disclaimer about service release versions to the download page. I hope the plugin can be of some help. I’m hoping to look at the PDF writer again before the next release to see what can be done to improve it.

2 Likes

Thank you so much for the PDF printer in Sasquatch. I haven’t been following the development of the Rhino PDF printer but I’m highly impressed by it’s speed and efficiency.

At the moment, it’s a little hard to specify page dimensions in Sasquatch. When I try and print an A4 page at 300dpi, the result is not ‘exactly’ A4 mm dimensions, which reduces it’s usefulness a bit for dimensioned drawings. Also control over the colour of the linework printed would be very helpful (Ideally this could be referenced in from whatever View Style the referenced Viewport uses- then setup could be entirely about defining viewports).

This is a separate idea entirely, but I wonder if a similar workflow could be integrated with the new Make2d Grasshopper components. If the PDF printer Component was able to print a set of reference curves with nothing else visible (from Make2D for example), and then combine it with a raster viewport style, I think the result could be a powerful tool. Unfortunately I think it might be a log time before Rhino is able to print Vectors with occlusion (or with solid hatches).

The Sasquatch PDF writer is using the Rhinocommon API to set page size. If it isn’t coming out as the correct size then it would be a bug McNeel should be made aware of. Setting it by pixel dimensions and dpi is currently the only way to set the size in the API. I’ll have to try reproducing that myself.

Combining it with the Make 2D component is what I was planning to do as well in my own workflow eventually. Unfortunately, the current Make 2D component has a habit of “losing” curves - there are a few curve categories that it doesn’t output that I am working on adding into a custom Make 2D component with a few extra controls to hopefully get better quality outputs.