To use values from a table in TouchDesigner to dynamically change the font size of a text object, you can use a combination of CHOPs (Channel Operators) and expressions. Here’s a general approach to achieve this:
-
Table DAT to CHOP: First, convert your table data into CHOP channels. You can use a DAT to CHOP operator for this. Make sure your table DAT has the ‘text’ and ‘x’ columns, and you’re interested in using the ‘x’ values to drive the font size.
-
Select CHOP: Use a Select CHOP to isolate the ‘x’ channel, which you want to use to control the font size.
-
Reference in Text TOP: In the parameters of the Text TOP (Text operator) that you’re using to display your text, you will set the font size to dynamically change based on the ‘x’ value. You can reference the CHOP channel directly in the parameter field where you set the font size.
Here’s a step-by-step guide:
- Add a DAT to CHOP operator and connect your Table DAT to it.
- In the DAT to CHOP parameters, select the column you want to convert to a channel, which in this case would be ‘x’.
- Add a Select CHOP and connect the DAT to CHOP to it.
- In the Select CHOP parameters, specify the channel you want to use, which would be the name of the ‘x’ column if it has been correctly converted to a channel.
- Go to your Text TOP where you’re displaying your text.
- Find the parameter where you set the font size. Instead of typing a static number, click on the parameter field and type the expression to reference your Select CHOP channel. It would look something like this:
op('select1')['x'], assuming ‘select1’ is the name of your Select CHOP and ‘x’ is the name of the channel you’re using.
This expression will now dynamically link the font size of the text in your Text TOP to the ‘x’ value from your table. As the ‘x’ values update every frame, the font size of your text will also update.
Make sure to adjust the expression based on the actual names of your operators and the scale of your ‘x’ values to font size. You might need to use some math in the expression (like multiplying or dividing the ‘x’ value) to get the font size to behave as you expect, depending on the range of values in your ‘x’ column.