Component Variables

From TouchDesigner Documentation
Jump to: navigation, search

Component Variables[edit]

Component variables are created local to any component, are usable anywhere in the component, and only in that component.

They are usually used with Tscript but can be used with Python, though in Python, properties in Extensions are more flexible.

In Python, you would use the var('VARNAME') expression to fetch a component variable. Setting them in python is difficult, something like op('../../local/set_variables')['varname',1] = value.

In Tscript, use the TScript: cvar command to create, list and delete component variables. Component variables for any component can be viewed in the Variables Dialog: Drag the component you want and drop it on the Variables dialog, this will create a tab displaying the component's local variables if any exist.

Component variables are evaluated hierarchically in TouchDesigner's networks. If a component variable is referenced and it is not defined in the local component, then it will search the parent component for the variable. This will continue until the variable is found or it reaches the top of the network hierarchy, /, the root.

How component variables work internally: Component variables are stored inside a Base COMP called local inside the component. The variables are defined inside local in a table DAT named variables. This DAT is fed by a Table DAT called set_variables, which is the DAT that the commands (TScript: cvar, rvar) use to insert variables in. This allows tables of other variables to be merged into variables. The TScript: cvar command can be used to list, set, or unset component variables.

NOTE: Root variables are simply component variables set at the root of the hierarchy, /.

An Operator Family that contains its own Network inside. There are twelve 3D Object Component and eight 2D Panel Component types. See also Network Path.

TouchDesigner's original built-in Command scripting language prior to Python.

An Operator Family that manipulates text strings: multi-line text or tables. Multi-line text is often a command Script, but can be any multi-line text. Tables are rows and columns of cells, each containing a text string.

TouchDesigner is a hierarchy of components. "root" is the top-most network in the hierarchy. The Path is simply /. A typical path is /project1/moviein1.