[SOLVED] How to pass a filename when printing into PDF?

I need to print about 1000 part drawings into separate PDF files named after their respective part names.
I want to Rhino script it too.

This is fairly ambitious - there are a HUGE number of factors to manage here, including views to print, drawing scale, layout on the page, margins, visibility of things, etc… The actual file naming procedure is the only easy part. Mac or PC?



I already have the “publishing” script that sends every individual part drawing to printer and exports the geometry into .DWG naming files appropriately for CNC. But PDFs are a different story.

How to pass a filename let’s say to CutePDF or Acrobat?.. And suppress the filename dialog box at the same time… No idea.

I struggle with this trying to pass the filename to PDFCreator but couldn’t get it to work. I don’t know if all the PDF printers use different arguments and which one Rhino works with.


Here Adobe PDF uses the 3dm filename as default, so that part should work. However, it does open its own save file dialog, and that window unfortunately does not respond to Rhino commands, so a manual press of the Enter key seems necessary for each file. :confused:

PDF995 has the option to supress the dialog and instead, it automatically names the print with the filename (or a default name you can set). Then you can set the folder to send the prints to. There are other naming options too which I haven’t explored. Also suppress the print preview option as this will stall and crash the script.

In Rhinoscript, by using
’Set objFSO = CreateObject(“Scripting.FileSystemObject”)'
Search - ‘CurrentModelInfo’ for examples.

Rhinoscript will find the pdf created and you can arrange to rename the print with the view or layout name - you’ll need to add a Rhino.Sleep of 3 seconds or so before file is renamed.

If you want to batch print, you can use a multilist box to choose the files to print from Rhino.ViewNames for layouts or Rhino.NamedViews for save views.

Within the script use Rhino.Command "_-Print _Go " to print the layouts or set up the print scale and other options if printing from modelspace.

Although you supress the PDF preview, you can see the Rhino print preview as the files are printed (every 3 secs or whatever period you set) - neat to watch…

Hope that’s of some use.

1 Like

^ Thanks! Renaming the default file name to desired after its creation makes perfect sense. That’s exactly what I was missing.

We found Bullzip PDF Writer which is totally free and has all the necessary options. Fast as a lightning too.

This improves the file write wait by a good bit too:

On Error Resume Next
chk = False
Rhino.Sleep 100 '— not sure if this is long enough to not fail. to be tested…
FSO.MoveFile DefName, TargetName
If FSO.FileExists(TargetName) Then chk = True
Loop While chk = False
On Error GoTo 0