Here’s how to set the default value for the FormatType list in the Capture Viewport dialog box.
from siutils import si # Application from siutils import log # LogMessage from siutils import disp # win32com.client.Dispatch from siutils import C # win32com.client.constants # Set the capture options oViewportCapture = si.Dictionary.GetObject("ViewportCapture") paramFormatType = si.Dictionary.GetObject( "ViewportCapture.FormatType" ) # Set default to JPEG paramFormatType.Value = 5 # Display Viewport Capture dialog si.CaptureViewport( 2, True ) # FormatType values # ----------------- # 0 Alias # 1 AVI # 2 BMP # 3 Cineon (DPX) # 4 Cineon (FIDO) # 5 JPEG # 6 Memory mapped # 7 mental ray color # 8 OpenEXR # 9 PGM # 10 Photoshop PSD # 11 Pict # 12 PNG # 13 PPM # 14 Quicktime # 15 SGI # 16 Softimage .pic # 17 Son Playstation2 TIM2/CLUT2 # 18 Targa # 19 Tiff # 20 Valve # 21 Wavefront # 22 YUV
If you are scripting a non-interactive viewport capture, you don’t use FormatType. Instead, the output file format is determined by the file extension of the output file name.
Here’s a Python version of the example on the CaptureViewport reference page.
from siutils import si # Application from siutils import log # LogMessage from siutils import disp # win32com.client.Dispatch from siutils import C # win32com.client.constants import win32com.client.dynamic # Get the current frame fc = si.ActiveProject.Properties("Play Control").Parameters("Current").Value # Set the capture options oViewportCapture = si.Dictionary.GetObject("ViewportCapture") # Capture a 1-frame sequence start = oViewportCapture.NestedObjects("Start Frame") win32com.client.dynamic.Dispatch(start).Value = fc end = oViewportCapture.NestedObjects("End Frame") win32com.client.dynamic.Dispatch(end).Value = fc # Specify the output file name # For scripted captures, the output file format is determined by the extension name = oViewportCapture.NestedObjects("File Name") win32com.client.dynamic.Dispatch(name).Value = "C:\\test.jpg" # No dialog si.CaptureViewport( 2, False );