Substituting Frame Padding for a Frame Number


You have a filename with Frame Padding, but need to get the filename for a specific frame in order to Read it in with Draft.


Simply use the ReplaceFilenameHashesWithNumber() helper function provided in Draft’s ParamParser helper script:

import Draft
from DraftParamParser import * #Needed to use the utility function

#sample inputs for this example
inFile = r"X:\project\shot\frame_list_####.png"
frameNumber = 24

swappedFileName = ReplaceFilenameHashesWithNumber( inFile, frameNumber )

frameImage = Draft.Image.ReadFromFile( swappedFileName )


The ReplaceFilenameHashesWithNumber() utility function does exactly what its name implies. It replaces hashes ('#') in the given file name (the first argument) with the given frame number (the second argument). The function will automatically pad the frame number with 0’s in order to match the length of the padding string.

It should be noted that Deadline will always try to pass the inFile argument to the Draft template as a hash-padded filename. If the Draft input is taken from the output of a rendering application that does not normally use '#' as a padding character (e.g., Maya), Deadline should detect this and swap it to '#' whenever possible