I'm looking at this again, and overall I am able to retrieve the path values and the redshift AOVs accordingly.
However, I'm still wondering if there's any built-in methods to resolve the tokenized paths. I'm using e.g.
c4d.modules.tokensystem.FilenameConvertTokens(token_path, rpd)
Or
c4d.modules.tokensystem.StringConvertTokens(token_path, rpd)
And it works fine, but it e.g. doesn't handle the output files "Name Format" of the render data where it always appends a frame number in a specific way and/or extension.
Is there any means where I can say use the Name Format to apply it to a filepath to see what it becomes? I'm essentially looking to do something similar as getting the Effective Path (per frame) as Redshift's AOV manager shows per AOV, but then also for the Single Image path and Multi-Pass image paths.
I'd rather not have to do things like this:
resolved = c4d.modules.tokensystem.FilenameConvertTokens(token_path, rpd)
# Apply the render data name format to the filepath
if name_format is not None and frame is not None:
head, tail = os.path.splitext(resolved)
# RDATA_NAMEFORMAT_0 = Name0000.TIF
# RDATA_NAMEFORMAT_1 = Name0000
# RDATA_NAMEFORMAT_2 = Name.0000
# RDATA_NAMEFORMAT_3 = Name000.TIF
# RDATA_NAMEFORMAT_4 = Name000
# RDATA_NAMEFORMAT_5 = Name.000
# RDATA_NAMEFORMAT_6 = Name.0000.TIF
padding = {
c4d.RDATA_NAMEFORMAT_0: 4,
c4d.RDATA_NAMEFORMAT_1: 4,
c4d.RDATA_NAMEFORMAT_2: 4,
c4d.RDATA_NAMEFORMAT_3: 3,
c4d.RDATA_NAMEFORMAT_4: 3,
c4d.RDATA_NAMEFORMAT_5: 3,
c4d.RDATA_NAMEFORMAT_6: 4,
}[name_format]
frame_str = str(frame).zfill(padding)
# Prefix frame number with a dot for specific name formats
if name_format in {
c4d.RDATA_NAMEFORMAT_2,
c4d.RDATA_NAMEFORMAT_5,
c4d.RDATA_NAMEFORMAT_6,
}:
frame_str = "." + frame_str
# Whenever the frame number directly follows the name and the name ends
# with a digit then C4D adds an underscore before the frame number.
elif head and head[-1].isdigit():
frame_str = "_" + frame_str
resolved = f"{head}{frame_str}{tail}"
And this does not even handle the exact extensions cases.
Any ideas?
