# Python rs.command("-\_print")

**URL:** <https://discourse.mcneel.com/t/python-rs-command-print/82597>\
**Category:** Scripting\
**Created:** [April 30, 2019, 8:24am UTC](https://discourse.mcneel.com/t/python-rs-command-print/82597 "2019-04-30T08:24:14Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![socken](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/socken/32/511469_2.png) [@socken](https://discourse.mcneel.com/u/socken)\
**Post date:** [April 30, 2019, 8:24am UTC](https://discourse.mcneel.com/t/python-rs-command-print/82597/1 "2019-04-30T08:24:14Z")

</div>

Hi,

Is there a way to use rs.command("-\_print") in python and not having to select preview before accually printing the document?

I see three options in ths dialog:  
Go, Setup, Preview.  
What does Go stand for? (nothing hapens when pressing it except the function ends)

Also is there a way to use -\_print to set name and destination of the printed document?

Hope this makes sence.  
Best regards

---

<div class="post-metadata">

**Author:** ![Asterisk](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/asterisk/32/480872_2.png) [@Asterisk](https://discourse.mcneel.com/u/Asterisk)\
**Post date:** [April 30, 2019, 12:56pm UTC](https://discourse.mcneel.com/t/python-rs-command-print/82597/2 "2019-04-30T12:56:11Z")

</div>

-\_Print \_Go \_Enter would try printing into your current print setup.

---

<div class="post-metadata">

**Author:** ![rgr](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/rgr/32/250899_2.png) [@rgr](https://discourse.mcneel.com/u/rgr)\
**Post date:** [April 30, 2019, 1:00pm UTC](https://discourse.mcneel.com/t/python-rs-command-print/82597/3 "2019-04-30T13:00:56Z")

</div>

rs.Command("\_-Print " + " \_Enter " + newFilename + " \_Enter", true);`

should work if you want to print into a new file with “newFilename” being the variable.

---

<div class="post-metadata">

**Author:** ![socken](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/socken/32/511469_2.png) [@socken](https://discourse.mcneel.com/u/socken)\
**Post date:** [April 30, 2019, 6:21pm UTC](https://discourse.mcneel.com/t/python-rs-command-print/82597/4 "2019-04-30T18:21:20Z")

</div>

Hi, Thanks for the replys.

I get nor of the two options to work.

Seams like I can’t input name or path to where the file is suppose to be placed.  
Shouldn’t the path+filename be possible to add under -\_print -\> \_setup -\> \_destination menu?

More suggestions are welcome.

Best regards

---

<div class="post-metadata">

**Author:** ![socken](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/socken/32/511469_2.png) [@socken](https://discourse.mcneel.com/u/socken)\
**Post date:** [May 1, 2019, 10:51am UTC](https://discourse.mcneel.com/t/python-rs-command-print/82597/5 "2019-05-01T10:51:13Z")

</div>

@stevebaer is it only me who can’t get this to work, or is it not suppose to be possible to print pdf directly from rs.command("-\_print")

Thanks in advance

---

<div class="post-metadata">

**Author:** ![Alain](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/alain/32/512812_2.png) [@Alain](https://discourse.mcneel.com/u/Alain)\
**Post date:** [May 1, 2019, 2:45pm UTC](https://discourse.mcneel.com/t/python-rs-command-print/82597/6 "2019-05-01T14:45:06Z")

</div>

Printing a Rhino document should work like described above. But since you’re printing a pdf you could try using `System.Diagnostics.Process`.  
Something like:

```auto
from System.Diagnostics import Process, ProcessStartInfo
p = Process( );
psi = ProcessStartInfo( )
psi.CreateNoWindow = True
psi.Verb = "print"
filename = r"myfile.pdf"
psi.FileName = filename
p.StartInfo = psi
p.Start( )

```

---

<div class="post-metadata">

**Author:** ![socken](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/socken/32/511469_2.png) [@socken](https://discourse.mcneel.com/u/socken)\
**Post date:** [May 1, 2019, 4:20pm UTC](https://discourse.mcneel.com/t/python-rs-command-print/82597/7 "2019-05-01T16:20:30Z")

</div>

Hi Alain,

Thanks for the help!  
That bit of code is a bit to much for me to take in =)  
Is that python language?  
I tried it out in the python editor (where the rest of my code is) but it only gave me:  
“The system cannot find the file specified”

The help is much appreciated!  
Best regards

---

<div class="post-metadata">

**Author:** ![socken](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/socken/32/511469_2.png) [@socken](https://discourse.mcneel.com/u/socken)\
**Post date:** [May 1, 2019, 4:57pm UTC](https://discourse.mcneel.com/t/python-rs-command-print/82597/8 "2019-05-01T16:57:48Z")

</div>

I noticed in [How to print a pdf from python?](https://discourse.mcneel.com/t/how-to-print-a-pdf-from-python/32796) that using  
\_-Print \_Setup \_Destination \_Printer “Microsoft Print to PDF” \_Enter \_Enter \_Go  
gives a new promt to:  
Save file name (browse):

But Changeing to:  
\_-Print \_Setup \_Destination \_Printer “Rhino PDF” \_Enter \_Enter \_Go  
Gives no option, instead I get to “save Print output As” dialog.

I would like to have it as the “Microsoft Print to PDF” option but with “Rhino PDF” printer.  
This way I don’t have to write a filename in the dialog box and pressing Enter.

Is this understandable?

Best regards

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [May 1, 2019, 5:23pm UTC](https://discourse.mcneel.com/t/python-rs-command-print/82597/9 "2019-05-01T17:23:46Z")

</div>

> [@socken](#):
>
> @stevebaer is it only me who can’t get this to work, or is it not suppose to be possible to print pdf directly from rs.command(“-\_print”)
> 
> Thanks in advance

I would recommend using the following technique for saving with Rhino PDF

> [@V6 Goal: True PDF Export](https://discourse.mcneel.com/t/v6-goal-true-pdf-export/40790/36):
>
> Here is how you would export every layout page to a PDF in python import Rhino import scriptcontext as sc import rhinoscriptsyntax as rs filename = rs.SaveFileName() pages = sc.doc.Views.GetPageViews() pdf = Rhino.FileIO.FilePdf.Create() dpi = 300 for page in pages: capture = Rhino.Display.ViewCaptureSettings(page, dpi) pdf.AddPage(capture) pdf.Write(filename) Does that work for you? The ViewCaptureSettings class is the key here. This is where all of the adjustments will be set for p…

---

<div class="post-metadata">

**Author:** ![socken](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/socken/32/511469_2.png) [@socken](https://discourse.mcneel.com/u/socken)\
**Post date:** [May 2, 2019, 6:31am UTC](https://discourse.mcneel.com/t/python-rs-command-print/82597/10 "2019-05-02T06:31:49Z")

</div>

Thanks @stevebaer!  
I knew I had read this somewhere.  
Sorry for the double posts

Best regrads

---

<div class="post-metadata">

**Author:** ![bradlcampbell](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bradlcampbell/32/769792_2.png) [@bradlcampbell](https://discourse.mcneel.com/u/bradlcampbell)\
**Post date:** [June 4, 2020, 9:29pm UTC](https://discourse.mcneel.com/t/python-rs-command-print/82597/11 "2020-06-04T21:29:44Z")

</div>

Steve, is there a similar method to capture the layout pages to PNGs? This is awesome, by the way!

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [June 4, 2020, 11:25pm UTC](https://discourse.mcneel.com/t/python-rs-command-print/82597/12 "2020-06-04T23:25:39Z")

</div>

Hey Brad,  
Capturing to images is handled by the `ViewCapture.CaptureToBitmap` functions  
[https://developer.rhino3d.com/api/RhinoCommon/html/M\_Rhino\_Display\_ViewCapture\_CaptureToBitmap.htm](https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Display_ViewCapture_CaptureToBitmap.htm)  
[https://developer.rhino3d.com/api/RhinoCommon/html/M\_Rhino\_Display\_ViewCapture\_CaptureToBitmap\_1.htm](https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Display_ViewCapture_CaptureToBitmap_1.htm)

---

<div class="post-metadata">

**Author:** ![bradlcampbell](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bradlcampbell/32/769792_2.png) [@bradlcampbell](https://discourse.mcneel.com/u/bradlcampbell)\
**Post date:** [June 5, 2020, 6:53pm UTC](https://discourse.mcneel.com/t/python-rs-command-print/82597/13 "2020-06-05T18:53:50Z")

</div>

Perfect! Thanks, Steve.

One interesting little thing… I have a display conduit that draws some geometry. I also have some clipping planes that apply to 2 of 5 DetailViewPorts in a layout page. Using the CaptureToBitmap method, the clipping planes are respected. However, they are not respected for the PDF export method.

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [June 6, 2020, 4:33am UTC](https://discourse.mcneel.com/t/python-rs-command-print/82597/14 "2020-06-06T04:33:41Z")

</div>

Hey Brad,  
Please start a new thread with details of the bug. It sounds like there is something to track down here. Thanks!
