c4d.modules.tokensystem¶
-
class
c4d.modules.
tokensystem
¶
The token system allows the use of expressions in file names. The API makes it is possible to handle these tokens.
New in version R17.048.
See also
Scripts for the Token System API in the examples.
Note
Since R21 it’s now possible to register your own custom token with c4d.plugins.RegisterToken()
and c4d.plugins.RegisterHiddenToken()
.
RenderPathData Dictionary
The rpData (RenderPathData) parameter of StringConvertTokens()
, FilenameConvertTokens()
, StringConvertTokensFilter()
and FilenameConvertTokensFilter()
accepts a dictionary with the data to convert tokens.
These are the keys that can be set in such dictionary:
_doc:
BaseDocument
_rData:
RenderData
_rBc:
BaseContainer
_take:
BaseTake
_frame: int
_layerName: str
_layerTypeName: str
_layerType: int
_isLight: bool
_lightNumber: int
_isMaterial: bool
_nodeName: str
_checkUnresolved: bool
For instance the dictionary can be initialized like this:
rpd = {'_doc': doc, '_rData': renderData, '_rBc': renderSettings, '_frame': 1}
Functions Signatures
Converts tokenized path string to standard string by replacing all Tokens with correct values if found. |
|
Converts tokenized path string to standard string by replacing all Tokens with correct values if found. |
|
|
Converts tokenized path string to standard String by replacing all Tokens with correct values if found.
|
|
Converts tokenized path string to standard string by replacing all Tokens with correct values if found.
|
Searches for the first Token in path.
|
|
Searches for the first Token in path.
|
|
Splits path in two parts if a Token is found as sub-folders and extracts root and filename path starting at sub-folder. |
|
Returns a list of all available Token entries. |
Functions Documentation
-
c4d.modules.tokensystem.
StringConvertTokens
(path, rpData)¶ Converts tokenized path string to standard string by replacing all Tokens with correct values if found.
- Parameters
path (str) – The original path string.
rpData (dict) – The data used to extract value for Tokens. See RenderPathData Dictionary.
- Return type
bool
- Returns
The converted string, or the original path if any error.
-
c4d.modules.tokensystem.
FilenameConvertTokens
(path, rpData)¶ Converts tokenized path string to standard string by replacing all Tokens with correct values if found.
- Parameters
path (str) – The original path filename.
rpData (dict) – The data used to extract value for Tokens. See RenderPathData Dictionary.
- Return type
bool
- Returns
The converted filename, or the original path if any error.
-
c4d.modules.tokensystem.
StringConvertTokensFilter
(path, rpData, exclude)¶ - Converts tokenized path string to standard String by replacing all Tokens with correct values if found.Tokens added to exclude array are ignored.
- Parameters
path (str) – The original path string.
rpData (dict) – The data used to extract value for Tokens. See RenderPathData Dictionary.
exclude (list) – A list of Tokens strings to be ignored.
- Return type
bool
- Returns
The converted string, or the original path if any error.
-
c4d.modules.tokensystem.
FilenameConvertTokensFilter
(path, rpData, exclude)¶ - Converts tokenized path string to standard string by replacing all Tokens with correct values if found.Tokens added to exclude array are ignored.
- Parameters
path (str) – The original path filename.
rpData (dict) – The data used to extract value for Tokens. See RenderPathData Dictionary.
exclude (list of str) – A list of Tokens strings to be ignored.
- Return type
bool
- Returns
The converted filename, or the original path if any error.
-
c4d.modules.tokensystem.
StringExtractRoot
(path)¶ - Searches for the first Token in path.If it is found and it is in-between “/..” returns the preceeding directory path string.
- Parameters
path (str) – The original path string.
- Return type
bool
- Returns
The root string path, or the original string if no Token is found.
-
c4d.modules.tokensystem.
FilenameExtractRoot
(path)¶ - Searches for the first Token in path.If it is found and it is in-between “/..” returns the preceeding directory path filename.
- Parameters
path (str) – The original path filename.
- Return type
bool
- Returns
The root filename path, or the original filename if no Token is found.
-
c4d.modules.tokensystem.
FilenameSlicePath
(path)¶ Splits path in two parts if a Token is found as sub-folders and extracts root and filename path starting at sub-folder.
- Parameters
path (str) – The original path filename.
- Return type
tuple(str, str)
- Returns
The root and filename paths.
-
c4d.modules.tokensystem.
GetAllTokenEntries
()¶ Returns a list of all available Token entries.
New in version R17.053.
For instance the following code prints all registered tokens
import c4d tokens = c4d.modules.tokensystem.GetAllTokenEntries() for entry in tokens: print entry
- Return type
list of dict
- Returns
All the registered Token information, or None if an error occurred.