Script Viewport Capture, how? [SOLVED]

Discussions about rendering in SOFTIMAGE©
User avatar
Draise
Posts: 809
Joined: 09 Oct 2012, 20:48
Skype: ondraise
Location: Colombia

Script Viewport Capture, how? [SOLVED]

Post by Draise » 19 Oct 2016, 22:08

I have developed a workflow with some passes from OpenGL. But, I would like to automate it. I have resolved to render out from the Sequencer camera and log the In/Outs for editing and composing later - but I want to automate the process of switching the passes then rendering out the capture - hopefully by script.

But the only script I see SI logging is the following:

Code: Select all

Application.CaptureViewport(3, 1)
Which opens up the View Port Capture panel - where I can setup things manually then render things out.. but I want to automate it via script.

I know how to open up the panel and switch passes automatically... but the manual dependance on the viewport Capture panel is a bit of a bottleneck.

How do I do this?
Last edited by Draise on 20 Oct 2016, 18:59, edited 1 time in total.

luceric
Posts: 1202
Joined: 22 Jun 2009, 00:08

Re: Script Viewport Capture, how?

Post by luceric » 20 Oct 2016, 14:49


User avatar
Draise
Posts: 809
Joined: 09 Oct 2012, 20:48
Skype: ondraise
Location: Colombia

Re: Script Viewport Capture, how?

Post by Draise » 20 Oct 2016, 18:58

Thanks for that. Silly me for not googling it.

Here is a two shot test script I built from those guidelines. Works like a charm!

Code: Select all

##Set Pass and viewport settings
#Application.SetCurrentPass("Passes.S01_AO")
#Application.SetValue("Views.ViewC.SequencerCamera.camdisp.hqvenable", True, "")
#Application.SetValue("Views.ViewC.SequencerCamera.camdisp.rtshadowenable", False, "")
#Application.SetValue("Views.ViewC.SequencerCamera.camdisp.rtaoradius", 0.18, "")
#Application.SetValue("Views.ViewC.SequencerCamera.camdisp.rtaoscale", 0.02, "")
#Application.SetValue("Views.ViewC.SequencerCamera.camdisp.rtaointensity", 1.75, "")
#Application.SetValue("Views.ViewC.SequencerCamera.camdisp.rtaoblursamples", 0, "")
#Application.SetValue("Views.ViewC.SequencerCamera.camdisp.multisampling", 0, "")

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 = 5 #fc for current frame
 
end = oViewportCapture.NestedObjects("End Frame")       
win32com.client.dynamic.Dispatch(end).Value = 8 #cf for current frame
 
# 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 = "\\\\RATOONZ3D-PC\\Projects\\3D MINI-PROJECTS\\Huellacas\\Render_Pictures\\RENDER\\S01\\S01_AO\\S01-All_AO_.png"

 
#Image scale W
scalex = oViewportCapture.NestedObjects("Width")
win32com.client.dynamic.Dispatch(scalex).Value = 800 
 
#Image scale H
scaley = oViewportCapture.NestedObjects("Height")
win32com.client.dynamic.Dispatch(scaley).Value = 600 

###Extra settings:###
 
#Image OpenGL AA 
gl = oViewportCapture.NestedObjects("OpenGL Anti-Aliasing")
win32com.client.dynamic.Dispatch(gl).Value = 0 

#Image Alpha
alpha = oViewportCapture.NestedObjects("Write Alpha")
win32com.client.dynamic.Dispatch(alpha).Value = 0 

#Launch Flipbook
launch = oViewportCapture.NestedObjects("Launch Flipbook")
win32com.client.dynamic.Dispatch(launch).Value = 0 

# No dialog
si.CaptureViewport( 3, False );




########### Take another shot


# Capture a frame sequence 
start1 = oViewportCapture.NestedObjects("Start Frame")
win32com.client.dynamic.Dispatch(start1).Value = 5 #fc for current frame
 
end1 = oViewportCapture.NestedObjects("End Frame")       
win32com.client.dynamic.Dispatch(end1).Value = 8 #cf for current frame
 
# Specify the output file name
# For scripted captures, the output file format is determined by the extension
name1 = oViewportCapture.NestedObjects("File Name")
win32com.client.dynamic.Dispatch(name1).Value = "\\\\RATOONZ3D-PC\\Projects\\3D MINI-PROJECTS\\Huellacas\\Render_Pictures\\RENDER\\S01\\S01_AO\\S01-All_AO_.png"

 
#Image scale W
scalex1 = oViewportCapture.NestedObjects("Width")
win32com.client.dynamic.Dispatch(scalex).Value = 400 
 
#Image scale H
scaley1 = oViewportCapture.NestedObjects("Height")
win32com.client.dynamic.Dispatch(scaley1).Value = 200 


# No dialog
si.CaptureViewport( 2, False );