@jcooper said in How to set completely custom render output filename?:
How do I control how much zero-padding is used for the $frame token? We typically use 4-digit, zero-padded frame tokens, but what if a situation called for, say, 6 digits?
Hi John, with regard to the $frametoken the zero-padding is hardcoded but as stated by @zipit you can workaround it by registering your token (see here)
.
How do I get at the RenderData for a specific renderer such as Redshift? For instance, it has its own "filename" attribute, but I don't know how to access/modify it from the python API.
You need to retrieve the RedShift BaseVideoPost and retrieve the corresponding data from its BaseContainer.
Check the code below
# Get the active RenderData
renderData = doc.GetActiveRenderData()
if renderData is None:
raise RuntimeError("Failed to retrieve the render data.")
# Get the active render settings
renderSettings = renderData.GetData()
if renderSettings is None:
raise RuntimeError("Failed to retrieve the render settings.")
# Get the first video post
videopost = renderData.GetFirstVideoPost()
if videopost is None:
raise RuntimeError("Failed to retrieve the videopost associated with the render data.")
# Search for the RedShift videopost
while videopost is not None and videopost.GetType() != 1036219:
print "RedShift is not set as renderer in the active RenderData, check next"
videopost = videopost.GetNext()
rsAOV = None
# Retrieve the AOV -> Filname param value
if videopost is not None and videopost.GetType() == 1036219:
rsAOV = videopost[c4d.REDSHIFT_RENDERER_AOV_PATH]
# Reads the path stored in the render setting
path = renderSettings[c4d.RDATA_PATH]
# Add token to the path
path = path + rsAOV
# Tokenizes the path from the render engine
rpd = {'_doc': doc, '_rData': renderData, '_rBc': renderSettings, '_frame': 1}
exclude = []
finalFilename = c4d.modules.tokensystem.FilenameConvertTokensFilter(path, rpd, exclude)+".png"
print finalFilename