Using Tokens with X-Particles

Tokens, introduced into more recent versions of Cinema 4D, are a means of easily using criteria such as render resolution, current frame, etc. in the name of a saved file. With this you can, for example, render a scene at different resolutions and have a series of files with different names corresponding to the scene resolution without having to enter the file name manually.

There are certain areas in X-Particles where tokens are useful when files are saved: these are Cache object, the Flowfield object when exporting .FGA maps, and the Data Exporter object. By far the most useful is the use of tokens in the Cache object.

Tokens in X-Particles work in much the same way and with the same names as the Cinema 4D tokens, with some slight changes to make the system more usable with X-Particles. For details of how to use tokens, please see the Cinema 4D documentation.

Available tokens

The following tokens, which have the same name as in Cinema 4D, are available:

Token Expands to
$prj The project file name (note: only the actual file name, not the full path to the file)
$camera The current camera name
$frame The current frame
$rs The name of the currently used render settings
$res The image resolution, e.g. 1280X720
$range The frame range of the animation
$fps The frame rate in frames per second

Note that the token '$prj' expands to the file name and does not include the full path to the document. If you need the full path to the document, without the actual file name, you can use a special token, '$xp_prp'.

The following Cinema 4D tokens are not currently supported: $take, $pass and $userpass.

Relative paths and tokens

Assume you have a saved scene file somewhere. You'd like to store the files from an X-Particles cache in a sub-folder of wherever the file is located. This seems like an ideal use of a relative path. In the Cache object folder, you type this:

What actually happens is that as soon as you move away from that field, you get an error message:

For some reason Cinema does not create the folder even though that is what you want it to do. Also, it helpfully removes the relative part of the path:

The only way round this is to make it clear that you really want it to create folders which don't exist. You can do it like so:

Cinema is entirely happy with this, and will create (at the location of the scene file) an folder called 'newfolder' and within that a folder called 'newsubfolder'. This is mildly irritating since you cannot create one level of subfolder.

You can, however, use tokens within this string. If the scene file is called 'cachetest1' and you enter this into the folder field:

Then at the scene file location you will see a folder named 'cachetest1' (this is from the token $prj, which returns the file name) and within that a folder called 'xpcache'. In that folder are your cache files.

Note that you can also enter this into the X-Particles preferences:

Then every time you create a new Cache object that string will be pre-entered into the folder field.