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 );
Steve! Is there a way to set a codec for quicktime’s .mov video capture through script?
You have to use presets:
http://softimage.wiki.softimage.com/index.php?title=Scripting_Tips_and_Tricks_(XSISDK)#Scripting_Viewport_Captures
Let me double-check whether something was added…I seem to remember seeing something about codecs recently…
Ok, in 2013 there will be a ViewportCapture.DSCodec parameter that you can script. In 2012 and earlier, you’ll have to use presets.
Good news! Can’t wait to see a complete list of bugfixes and SDK enhancements of 2013 🙂
Thanks for help! I’ll try presets out
Pardon my ignorance Stephen, but why cant one do stuff like this:
oViewportCapture = si.Dictionary.GetObject(“ViewportCapture”)
oViewportCapture.Start = ##
and instead must go with the NestedObjects method?
it seems to be the only way it works, but it looks inconsistent with everything else
Hi Gustavo
The ViewportCapture object isn’t an X3DObject and it doesn’t expose its parameters through the object model. If you look in the SDK Explorer, you’ll see that ViewportCapture is a CollectionItemLegacy object that doesn’t support the Parameters property (ViewportCapture used to be an SIObject, which again, did not support the Parameters property).
You could skip the NestedObjects step and use Dictionary.GetObject to get the parameters.
And ViewportCapture was always scriptable with GetValue and SetValue.