Python Render Token - no frame number?
-
I was just playing with the render tokens in Python, and I found some strange behavior in the example
py_render_token_r21
.I modified the code a little to give me three different render tokens but the
PythonFrameToken
function should work the same as the Maxon original. I just added a test forNOTOK
here:import c4d, time def PythonFrameToken(data): """ data[4], # The frame number used for rendering or NOTOK if the frame is not yet recognized. """ print "Token $PythonTokenFrm replaced:", str(data[4]), data[4] if data[4] == c4d.NOTOK: return "NOTOK" else: return str(data[4]) def PythonTimeToken(data): return time.strftime("%a in %B") # Weekday in Month def PythonFirstObjectToken(data): obj = data[0].GetFirstObject() if obj == None: return "None" else: return obj.GetName() if __name__=="__main__": for registeredToken in c4d.modules.tokensystem.GetAllTokenEntries(): print registeredToken if registeredToken.get("_token") in ["PythonTokenFrm", "PythonTokenTime", "PythonTokenFirstObject"]: exit() c4d.plugins.RegisterToken("PythonTokenFrm", "This Python Token shows the frame", "001", PythonFrameToken) c4d.plugins.RegisterToken("PythonTokenTime", "This Python Token shows the time", "Sat in June", PythonTimeToken) c4d.plugins.RegisterToken("PythonTokenFirstObject", "This Python Token shows the name of the first object", "MyObject", PythonFirstObjectToken)
(I am aware of the problem described here:
https://developers.maxon.net/forum/topic/12162/custom-tokens-with-team-render-server
so I know this may not work on TeamRender, but I'm working on full GUI C4D so this does not apply.)And here's the issue:
The functionPythonFrameToken
returnsNOTOK
in the crucial call. So, the file name ultimately contains "NOTOK" instead of the actual frame number.
The other two tokens work fine as expected.Looking at the console output,
PythonFrameToken
is called several times; here rendering frame 15-16:Token $PythonTokenFrm replaced: -1 -1 Token $PythonTokenFrm replaced: -1 -1 Token $PythonTokenFrm replaced: -1 -1 Token $PythonTokenFrm replaced: 15 15 Token $PythonTokenFrm replaced: -100000000 -100000000 Token $PythonTokenFrm replaced: 15 15 Token $PythonTokenFrm replaced: -100000000 -100000000 Token $PythonTokenFrm replaced: 15 15 Token $PythonTokenFrm replaced: 15 15 Token $PythonTokenFrm replaced: -100000000 -100000000 Token $PythonTokenFrm replaced: 16 16 Token $PythonTokenFrm replaced: -100000000 -100000000 Token $PythonTokenFrm replaced: 16 16 Token $PythonTokenFrm replaced: 16 16
At some point,
data[4]
obviously yields the correct value, but the filenames are still wrong.
It does not matter whether the path string contains a path or just a filename without path component.This comes from an official example for R21 though - so I wonder what's wrong.
-
Hi @Cairyn, this also impacts C++, I don't see any workarounds, unfortunately, I've opened a Bugs report about it.
Cheers,
Maxime. -
@m_adam Thanks for the confirmation!
(I swear I'm not doing this on purpose...)