from pyfbsdk import *
import os
lRenderPrefix = 'Render'
lformat = '.tif'
gApplication = FBApplication()
gSystem = FBSystem()
lControl = FBPlayerControl()
timeSpan = gSystem.CurrentTake.LocalTimeSpan
lStart = timeSpan.GetStart()
lStop = timeSpan.GetStop()
lStepFrame = 1
lFrameRate = lControl.GetTransportFpsValue()
def RenderLayer ( pPath,pLayerName ):
lRenderPath = "%s\%s_%s" % ( pPath,pLayerName,lformat )
lOptions = FBVideoGrabber().GetOptions()
lOptions.ViewingMode = FBVideoRenderViewingMode().FBViewingModeCurrent
lOptions.TimeSpan = timeSpan
lOptions.TimeSteps = FBTime(0, 0, 0, 1)
lOptions.CameraResolution = FBCameraResolutionMode().kFBResolutionCustom
lOptions.AntiAliasing = False
lOptions.RenderAudio = False
lOptions.FieldMode = FBVideoRenderFieldMode().FBFieldModeNoField
lOptions.BitsPerPixel = FBVideoRenderDepth().FBVideoRender24Bits
lOptions.ShowCameraLabel = False
lOptions.ShowSafeArea = False
lOptions.OutputFileName = pPath
lOptions.ShowTimeCode = True
lOptions.OutputFileName = lRenderPath
gApplication.FileRender( lOptions )
lShow = {}
for lGroups in FBSystem().Scene.Groups:
lShow[lGroups.Name]=lGroups.Show
for lCamera in FBSystem().Scene.Cameras:
lCamera.ViewShowAxis = False
lCamera.ViewShowGrid = False
lFp = FBFolderPopup()
lFp.Caption = "Select a folder to put your Rendered Layers:"
lFp.Path = r"C:\temp"
lRes = lFp.Execute()
if lRes:
lfolder = FBMessageBoxGetUserValue( "Create subfolder for render layers: " , "Warning: will overwrite existing ", "MyRenderLayers", FBPopupInputType.kFBPopupString, "Ok" )
if lfolder[0]:
print "Creating subfolder %s" % lfolder[1]
if not os.path.exists("%s\\%s" % ( lFp.Path,lfolder[1] )):
os.mkdir("%s\\%s" % ( lFp.Path,lfolder[1] ))
lFp.Path = "%s\%s" % (lFp.Path,lfolder[1])
else:
FBMessageBox( "Result", "Got an error", "Ok" )
del( lfolder )
for lGroups in FBSystem().Scene.Groups:
lGroups.Show = False
for lGroups in FBSystem().Scene.Groups:
if lGroups.Name.startswith( lRenderPrefix ):
lGroups.Show = True
print 'Rendering Layer ' + lGroups.Name.lstrip( lRenderPrefix )
RenderLayer(lFp.Path,lGroups.Name.lstrip( lRenderPrefix ))
print 'Done'
lGroups.Show = False
for lCamera in FBSystem().Scene.Cameras:
lCamera.ViewShowAxis = True
lCamera.ViewShowGrid = True
for lGroups in FBSystem().Scene.Groups:
lGroups.Show = lShow[lGroups.Name]