With "-Print", can I indicate "Image File (PNG, BMP, TIF, …)"?

Hi,

I am wirting a script to make batch plot layouts.
Not only print PDF, I want also to print images from layouts.
Is there any way to indicate “Image File (PNG, BMP, TIF, …)” as printer name inside of command of “-Print”?

Thank you so much.

Hi,

You can select “Image File (PNG, BMP, TIF, …)” in the Print dialog, but even from scripted -Print it pops a Save As dialog for every page — so it won’t work for an unattended batch loop.

For batch-plotting layouts to images, use RhinoCommon’s ViewCapture instead. It’s the same print engine underneath, so it honors the layout page size and print widths:

import System
import scriptcontext as sc
from Rhino.Display import ViewCapture, ViewCaptureSettings

dpi = 300
folder = r"C:\out"

for page in sc.doc.Views.GetPageViews():
    settings = ViewCaptureSettings(page, dpi)   # page size auto-computed from the layout
    settings.RasterMode = True                  # raster, like the Print dialog's Raster Output
    bmp = ViewCapture.CaptureToBitmap(settings)
    if bmp:
        bmp.Save(System.IO.Path.Combine(folder, page.PageName + ".png"),
                 System.Drawing.Imaging.ImageFormat.Png)

Save with whatever ImageFormat you want — Png/Bmp/Tiff/Jpeg are all there.

If you just need an image of a view rather than a layout page, -ViewCaptureToFile is fully scriptable too: ViewCaptureToFile | Rhino 3-D modeling

Hi **Japhy

THank you so much for your replay!
I undestand. I will make script with your code ! thanks again !
Helps a lot your prompt response !!!**

Hi Japhy

I copied your code and it didnt run properly.

with ChatGPT finally I achieved the code which works. but it seems odd.
Could you verify and please tell me why we have to declare “_overloads_”?

is this normal way??

import System
import scriptcontext as sc
from Rhino.Display import ViewCapture, ViewCaptureSettings

dpi = 300
folder = r"C:\Users\Desktop\New folder"


for page in sc.doc.Views.GetPageViews():
    settings = ViewCaptureSettings(page, dpi)   # page size auto-computed from the layout
    settings.RasterMode = True                  # raster, like the Print dialog's Raster Output
    bmp = ViewCapture.CaptureToBitmap.__overloads__[ViewCaptureSettings](settings)
    if bmp:
        bmp.Save(System.IO.Path.Combine(folder, page.PageName + ".png"),
                 System.Drawing.Imaging.ImageFormat.Png)