Formatted String Generator
Intro
Build a custom string by combining an array of input strings.
UI
Formatted String - Enter a string. Use {<indexNumber>}
to reference an index.
0:String - The first index in the array.
Formatting Strings
Each string within the array can be referenced within the Formatted String by wrapping its index in curly brackets. The output string generated will replace {0}
with the contents entered into 0:String.
- Create a String Generator.
- Set the Generator to Formatted String.
- Enter
Here's to the {0} ones.
into the Formatted String. - Enter
crazy
into 0:String. - Create a Text Shape.
- Connect stringGenerator.id→textShape.string.
{0}
from the Formatted String has been replaced with crazy
so the Text Shape outputs "Here's to the crazy ones.".
Values
The Formatted String Generator only accepts strings as inputs but a Value String Generator can be used to convert values into a string. For example, the Width of a Rectangle can be added to a Formatted String Generator by first connecting it to a Value String Generator and then connecting the Value String Generator to an index of the Formatted String Generator.
Dynamic File Names
The Formatted String Generator is also a good way to generate dynamic file names. This can be useful in combination with Dynamic Rendering. Simply connect the Formatted String Generator to the File Name of a Render Queue Item in the Render Manager – each time the Dynamic Index increments, a new file name is generated.
The Formatted String Generator can be used to combine various inputs including data from a Spreadsheet Utility, Render Tokens and values from the Composition to create bespoke, unique file names.
If external data via a Spreadsheet Utility or the Index of an Array is already connected to the Render Manager's Dynamic Index, each render will be given a unique file name generated by the Formatted String Generator.
- Import a .csv or Google Sheet Asset containing the following data to the Assets Window:
Colour | Hex |
---|---|
Red | #ff0000 |
Green | #00ff00 |
Blue | #0000ff |
- Drag the Asset into the Viewport to create a Spreadsheet Utility.
- Set the Spreadsheet's Column Title to Colour.
- Check Fixed Row.
- Connect the Render Manager's Dynamic Index to the Spreadsheet's Row Index.
- Create a String Generator.
- Set the Generator to Formatted String.
- Enter
Colour-{0}
into the Formatted String. - Connect spreadsheet.id→stringGenerator.array.0 (the 0:String attribute).
- Connect the String Generator to the Render Queue Item's File Name.
When Dynamic Rendering, each file will be named Colour-Red
, Colour-Green
, Colour-Blue
.
Note that Render Tokens do not inherit the styling that confirms they are valid within a Formatted String Generator so ensure they are spelt and formatted correctly. The styling will appear when connected to a Render Queue Item's File Name so this can be used to ensure they have been correctly entered.
Non indexed entries (empty curly brackets) are enumerated on based on their position in the string. For example, a string containing {} {} {}
is the equivalent of {0} {1} {2}
. This is also true where indexed and non indexed entries exist in the same string. For example, {2} {} {1} {}
would be interpreted as {2} {0} {1} {1}