Animating Dictionaries in TouchDesigner

I came across the need to animate CHOPs based on a cued sequence. I have found that the animation chop is a little difficult to work with quickly in a theatre tech week scenario, so I created a way of cuing parameters with python dictionaries and storage.

 

 

A dictionary in Python is a data structure that works like an array or list, but instead of referring to things by index, it refers to things by a key. Matthew Ragan has a fantastic video about how storing lists and dictionaries here: http://matthewragan.com/2015/03/31/thp-494-598-python-lists-touchdesigner/
For more information refer to this documentation: https://docs.python.org/2/tutorial/datastructures.html

The recording all takes place in this network.

cue_Comp

CHOP values are converted into a table and then this script stores the values as a dictionary. The stored keys for each dictionary  correspond to the cue its recorded under. The positions are stored using a for loop like Matt showed in his video. A stored Dictionary looks like this:

Examine_Storage.PNG

I can fetch any of these dictionaries at anytime to transition between them. The “GO” button drives a count that keeps track of where we currently are in the cue stack. When this count changes it sets the value of a table to be the cue we want to call. This table update triggers a DAT Execute which runs this script:

AB_Controller.PNG

This controls the AB Switcher that runs the animation. I made a module for unpacking dictionaries into a table call “cues.unpackCue()”. Inside a base called local and another base called modules I made a text DAT to write this module. Unpack_Cues

There are 3 arguments passed into this function, num, to, and t. “num” is the cue number you want to unpack, to is the table you want to unpack it in, and t is to set the time pulled from the dictionary.

This all gets unpacked at the AB switcher in the table that isn’t the last one used (the one that would be up if we were playing). Once a cue is unpacked, time is loaded and switched so a speed increments or decrements, in turn driving a cross.

Recording all of this happens in this script which is run when the record button is hit.

StoreScript