Creating custom render tokens for Cinema 4D is very simple with Python. First you want to loop through tokens and check that there is no duplicates.
if __name__=="__main__": for registeredToken in c4d.modules.tokensystem.GetAllTokenEntries(): if registeredToken.get("_token") in ["my_token"]: exit()
Next you register your custom token with following command:
c4d.plugins.RegisterToken("my_token", "Comment", "Example value", MyFunction)
Last but not least you need the function that returns some kind of string that the token outputs:
def MyFunction(data): return "myString" # Replace this with your more advanced script
Here is my collection of custom tokens that might be useful.
- Date Year Full (2021) – Token: $YYYY
- Date Year Short (21) – Token: $YY
- Date Month (01) – Token: $MM
- Date Day (16) – Token: $DD
- Date Hour (18) – Token: $hh
- Date Minute (42) – Token: $mm
- Date Second (10) – Token: $ss
- PC Name (String) – Token: $pcname
- Username (String) – Token: $pcuser
- Render Engine (Redshift) – Token: $renderer
Place the folder in the zip file to Cinema 4D’s plug-in folder.