Hey @GordOrb,
This is not possible. You are not really meant to distinguish the file names you are writing for. I also do not understand the purpose of doing what you want to do. You can already name the beauty file and the multipass file differently in the UI. And when you write out each pass on its own, Cinema 4D will already name them differently for you.
There will be singular token call for all pass layers, and before that a call for the RGB/beauty layer. None of the calls for naming the file contains pass information. The inner logic of it seems to be that you first get the call for evaluating the token for a filename and after that the actual passes.
The purpose of some fields in the passed data is probably more of internal than public nature, since you cannot really do much with that info due to how the token calls are coming in. In some contexts these fields might be useful when you use the Token System (C++ Manual) more manually. But at least for the passes case, this is not really true either, because when you start to render manually, you will have to fill in the pass data on your own when constructing a RenderPathData.
So, long story short: this is not really possible, at least in the intended way. Upon having a closer look at the time stamps and my file output, I realized that you could try to rely on the rule 'the call after the call for the RGB pass', because that is at least how it works in my example.
isMultipass: '1', pname: ' ', ptype: ' ', pid: ' -1', t: 9366346949848 // First call, irrelevant
isMultipass: '1', pname: ' ', ptype: ' ', pid: ' -1', t: 9367113676312 // Time stamp of saved RGB/beauty.
isMultipass: '1', pname: ' RGB', ptype: ' RGB', pid: ' -1', t: 9367113987757 // RGB/beauty pass
isMultipass: '1', pname: ' ', ptype: ' ', pid: ' -1', t: 9367114252401 // Time stamp of all passes.
...
If this works, this would be hack, and it would be then up to you establish if that holds true or not. To establish "what is the last call", you could have some global list into which you push things. Make sure not to store any Cinema 4D rendering data in that global list (BaseDocument, BaseContainer, RenderData) or you might end up in world of hurt.
Cheers,
Ferdinand
Written Files:
fc970227-90fb-437e-b5d7-b7a25a9e2da0-image.png
My console dump, here I search for the time stamp 9367114252401 of my files, it is the fourth call, long before we get the calls for the passes. The only thing that comes before is a call for the RGB, i. e., the beauty pass.
b5e92449-2ffa-4d4b-a0b7-de02968635d8-image.png
Code:
"""
"""
import c4d
import mxutils
import time
def get_render_type(data: c4d.BaseContainer) -> str:
"""Dumps information about #data into the token and the console.
"""
# Get the render document #rdoc, and build a string for the UUID of rdoc as well as its memory
# location and #data. Unsurprisingly, the mem locs are meaningless here in Python as everything
# must be wrapped by Python objects in each call. In C++ you might be able to establish "sameness"
# between calls by the location of #data (the rendering document which is used is always the
# same as shown by its UUID). But I doubt that you will have luck with #data in C++, because it
# is likely constructed for each call there too (and not reused).
rdoc: c4d.documents.BaseDocument = mxutils.CheckType(data[0], c4d.documents.BaseDocument)
uuid: bytes = bytes(rdoc.FindUniqueID(c4d.MAXON_CREATOR_ID))
ident: str = f"doc-uuid: {uuid}, doc-mem: {id(rdoc)}, bc-mem: {id(data)}"
# Build the token.
token: str = (f"isMultipass: '{rdoc.GetActiveRenderData()[c4d.RDATA_MULTIPASS_ENABLE]}', "
f"pname: '{data[5]:>20}', ptype: '{data[6]:>10}', pid: '{data[7]:>3}', t: {time.perf_counter_ns()}")
print (ident, token)
return token
if __name__ == "__main__":
if "r_type" not in set(item["_token"] for item in c4d.modules.tokensystem.GetAllTokenEntries()):
c4d.plugins.RegisterToken("r_type", "[Render] Type", "reg/multi", get_render_type)