Essential Python Expressions

Curriculum Navigator:

If you’re viewing this page from the TouchDesigner curriculum explorer, you can use the buttons below to interact with this topic.

Overview:

There are lots of uses of Python in TouchDesigner, but there are also some essential Python expressions and operations that make life easier. The first of these are fast references to time. For installations and performances we often want to use a controllable source of time (a Timer CHOP or a Speed CHOP network for example) – but sometimes we just need an expression to see some animation in our network. That’s where we can use:

absTime.seconds

or

absTime.frame

These two expressions will return the absolute time in seconds or frames since TouchDesigner started running.

Python expressions can be used to do lots of different operations, and an important one is mathematical operations. The math module for Python is imported when TouchDesigner starts, and means we can use things like math.cos() and math.sin() in our expressions.

We reference parameters frequently in TouchDesigner, especially when using Python, and it’s important to know that we can access parameters two different ways. We can use the syntax:

op(‘some_op’).par.theParName

or

op(‘some_op’).par[‘theParName’]


References:
Scroll to Top