Skip to main content

13 posts tagged with "Python"

Posts about using Python

View All Tags

Python in TouchDesigner | Extensions

· 8 min read
Matthew Ragan
Pixel Pusher

Rounding out some of our work here with Python is to look extensions. If you've been following along with other posts you've probably already looked over some extensions in this post. If you're brand new to this idea, check out that example first.

Rather than re-inventing the wheel and setting up a completely new example, let's instead look at our previous example of making a logger and see how that would be different with extensions as compared to a module on demand.

A warning for those following along at home, we're now knee deep in Python territory, so what' we'll find here is less specific to TouchDesigner and more of a look at using Classes in Python.

Python in TouchDesigner | Modules

· 13 min read
Matthew Ragan
Pixel Pusher

There are a number of ways that we might use modules on demand in TouchDesigner. Before we get too far along, however, we might first ask "what is a module on demand?"

According to the TouchDesigner wiki:

The MOD class provides access to Module On Demand object, which allows DATs to be dynamically imported as modules. It can be accessed with the mod object, found in the automatically imported td module.

Alternatively, one can use the regular python statement: import. Use of the import statement is limited to modules in the search path, where as the mod format allows complete statements in one line, which is more useful for entering expressions. Also note that DAT modules cannot be organized into packages as regular file system based python modules can be.

Python in TouchDesigner | Dictionary Loops

· 20 min read
Matthew Ragan
Pixel Pusher

We've looked at dictionaries as data structures already, and have gotten a peak into how powerful then can be for storing and manipulating data. That's all well and good, but wouldn't it be lovely if we could loop through the contents of our dictionaries the same way we can loop through list items?

In fact, we can.

Python in TouchDesigner | OP Class

· 8 min read
Matthew Ragan
Pixel Pusher

The OP Class

Taking some time to really understand how you might take better advantage of classes when using Python in TouchDesigner is well worth the time and effort – even if frustrating and intimidating at first. Chances are, you've already used some class methods without even knowing it, and here we're going to take a quick opportunity to better understand them, and how you might use them.

Python in TouchDesigner | Executes

· 15 min read
Matthew Ragan
Pixel Pusher

Now that we know a little more about how functions work we're ready to dig in a little deeper when it comes to working with execute DATs. There are a number of different executes, and they all work on a similar principle – a target operator is watched for changes, and when a change occurs a function is executed. Let's first look at a very simple example with a CHOP execute.

Python in TouchDesigner | Dictionaries

· 10 min read
Matthew Ragan
Pixel Pusher

Part 1

Core Concepts

  • Dictionaries – a structure and a concept
  • Looking at Dictionaries and Lists side by side
  • What are key value pairs
  • Retrieving values from dictionaries
  • Retrieving .keys() and .values()
  • Adding items to dictionaries
  • Nested data structures
  • A better text formatting approach with .format() (a big thank you to Willy Nolan for setting me on the right path with text formatting in Python 3)