Tag Archives: OP

Nov 13 2014

EXECUTE DATs tutorial.

The EXECUTE DATs. TouchDesigner 088. 2014.
The EXECUTE DATs are a family of Operators that can run scripts on TouchDesigner events. These are the most powerful group of DATs, and are used extensively in building interactive networks. This is a special tutorial covering 6 DATs.

1
00:00:00,333 –> 00:00:06,267
This tutorial will focus on the
family of execute DATs.

2
00:00:06,267 –> 00:00:13,267
6 DATs that run scripts when
specific events happen in Touch
Designer.

3
00:00:13,267 –> 00:00:20,300
I built 6 example networks,
let’s start with the execute
DAT.

4
00:00:20,300 –> 00:00:27,267
The execute DAT can respond to 6
possible events, or processes.

5
00:00:27,267 –> 00:00:42,900
In order to work, the execute
DAT must have a Python script,
or snippet, within the targeted
Python method, as well as its
corresponding toggle enabled in
the parameters panel.

6
00:00:42,900 –> 00:00:55,100
This example creates 3 actions,
1 on frame start, 1 on frame
end, and 1 when the play state
changes.

7
00:00:55,100 –> 00:00:59,300
I’ve inserted a line into the
“frameStart” method.

8
00:00:59,300 –> 00:01:06,400
It fills the cell in row index
1, and column index 1, with the
frame number.

9
00:01:06,400 –> 00:01:11,133
We fill the next cell with the
frame number on frame end.

10
00:01:11,133 –> 00:01:18,333
The “playState” method has some
simple logic that alerts us to
the play head state.

11
00:01:18,333 –> 00:01:34,833
The execute DAT is commonly used
to monitor Touch Designer
processes, or, by using the
“start” method, to create setup
routines that prepare a network
when the program is launched.

12
00:01:34,833 –> 00:01:42,867
I often use the “exit” method to
perform clean up when Touch
Designer exits.

13
00:01:42,867 –> 00:01:48,500
Next let’s look at the chop
execute DAT.

14
00:01:48,500 –> 00:01:53,133
This operator is extremely
powerful and useful.

15
00:01:53,133 –> 00:02:06,333
It provides a simple framework
for you to convert CHOP
processes, to analyze CHOP
behaviors, and to build logic
based on CHOP events.

16
00:02:06,333 –> 00:02:11,767
You must first provide the DAT
with a reference CHOP.

17
00:02:11,767 –> 00:02:14,567
This is the CHOP that will be
monitored.

18
00:02:14,567 –> 00:02:23,867
You can toggle the “Active”
parameter to start or stop the
DAT’s execution.

19
00:02:23,867 –> 00:02:29,500
There are 5 methods that
correspond to CHOP events.

20
00:02:29,500 –> 00:02:41,300
It’s very important to realize
that ON is defined as any value
greater than 0, and OFF is
defined as 0.

21
00:02:41,300 –> 00:03:01,000
I’ve built some Python snippets
to showcase some simple ON/OFF
state logic, and I’ve used the
“valueChange” method to fill a
table cell with the evaluation
of the beat CHOP’s first
channel.

22
00:03:01,000 –> 00:03:14,400
This setup can help you
visualize the nature of OFF/ON
state logic, and help you
understand the options you have
for designing CHOP execution
timing.

23
00:03:14,400 –> 00:03:18,033
Next we’ll look at the dat
execute DAT.

24
00:03:18,033 –> 00:03:24,967
This operator and workflow is
very similar to that of the CHOP
execute DAT.

25
00:03:24,967 –> 00:03:30,433
Here I’ve built a representation
of a common Touch Designer
network.

26
00:03:30,433 –> 00:03:37,167
The end result is a table that
changes dynamically based on
user input.

27
00:03:37,167 –> 00:03:46,200
The dat execute DAT monitors
this table, and outputs data
based on the table’s state.

28
00:03:46,200 –> 00:03:51,233
There are 5 possible methods, or
states, we can monitor.

29
00:03:51,233 –> 00:04:05,667
The size and shape of the table
will change based on user
activity, and we can use this
activity to trigger any other
sort of logic in Touch Designer.

30
00:04:05,667 –> 00:04:18,833
Touch Designer has several
powerful methods for each
operator, including the table
DAT, that can help you modify or
access information about that
DAT.

31
00:04:18,833 –> 00:04:30,667
Here, I’ve used the “numRows”
and “numCols” members of the
table DAT class, to report the
size and shape of the table.

32
00:04:30,667 –> 00:04:42,667
I designed this network as a way
to illustrate a technique for
changing a TOP into a CHOP, then
into a DAT.

33
00:04:42,667 –> 00:04:54,833
By using the button, we can add
a colored cell to the table, and
by using the sliders, we can
alter the shape of the table.

34
00:04:54,833 –> 00:05:03,433
Notice how the dat execute DAT
creates a response to the
table’s changing shape.

35
00:05:03,433 –> 00:05:19,967
Keep in mind, the logic I’ve
written for the changing cell
method does not report the cell
ID, but only keeps track of the
fact that an unknown cell has
changed.

36
00:05:19,967 –> 00:05:26,533
You can use this network as a
basis for creating more
sophisticated logic.

37
00:05:26,533 –> 00:05:41,233
For example, you could restrict
user input to certain
specifications, or create
triggers that execute other
behaviors based on certain
criteria.

38
00:05:41,233 –> 00:05:45,200
Let’s take a look at the op
execute DAT.

39
00:05:45,200 –> 00:05:51,833
This DAT is more generic than
the chop or dat execute DATs.

40
00:05:51,833 –> 00:05:56,467
It can monitor any operator,
including TOPs.

41
00:05:56,467 –> 00:06:02,667
It is a common practice to
change Touch Designer networks
dynamically.

42
00:06:02,667 –> 00:06:11,300
Using an op execute DAT is a
good way to keep track of
changes to Touch Designer
networks.

43
00:06:11,300 –> 00:06:19,067
I’m using an info CHOP to report
information about the blur TOP.

44
00:06:19,067 –> 00:06:23,633
The info CHOP is an extremely
important operator.

45
00:06:23,633 –> 00:06:33,000
It’s used very commonly in Touch
Designer, and it’s a great
companion to the op execute DAT.

46
00:06:33,000 –> 00:06:49,633
I’m using the info CHOP to
report the number of times the
blur TOP has cooked, and I’m
using the op execute DAT to
report when that state changes.

47
00:06:49,633 –> 00:06:53,867
The op execute DAT can monitor
flag states.

48
00:06:53,867 –> 00:06:58,733
Flags are the buttons running
down the left side of an
operator.

49
00:06:58,733 –> 00:07:06,233
Bypass is a commonly used flag;
it will stop an operator from
cooking.

50
00:07:06,233 –> 00:07:14,267
Remember, in order to work
properly, the op execute DAT
must have an operator to
monitor.

51
00:07:14,267 –> 00:07:26,133
In this case the blur TOP, and
the methods we wish to employ
must have their corresponding
toggle enabled in the parameters
panel.

52
00:07:26,133 –> 00:07:33,167
The “wireChange” method lets us
monitor the inputs and outputs
of any operator.

53
00:07:33,167 –> 00:07:42,333
When we change the blur TOP’s
input, we see the op execute DAT
can report this change.

54
00:07:42,333 –> 00:07:49,667
We see that still images don’t
cook unless forced to, and
movies cook every frame.

55
00:07:49,667 –> 00:07:55,067
We can also see the effect of
enabling the bypass flag.

56
00:07:55,067 –> 00:07:59,067
Now let’s look at the panel
execute DAT.

57
00:07:59,067 –> 00:08:06,433
The panel execute DAT is similar
to the chop execute DAT, but it
monitors panels.

58
00:08:06,433 –> 00:08:16,333
Panels are a special type of
component, they are used to
create customized interactive
controls.

59
00:08:16,333 –> 00:08:22,367
They are often used to create
user interface elements.

60
00:08:22,367 –> 00:08:31,867
Here, I’m monitoring a field
panel. A field panel allows
users to type text strings into
a field.

61
00:08:31,867 –> 00:08:37,267
The panel execute DAT has a
parameter named “Panel Value”.

62
00:08:37,267 –> 00:08:45,400
By clicking the arrow button to
the right, we can see a list of
all the available values the
panel offers.

63
00:08:45,400 –> 00:08:55,867
I’ve added a panel CHOP, which
also monitors the field panel,
to show you some of the values
that are interactively
monitored.

64
00:08:55,867 –> 00:09:02,800
Panels are accessed under the
components tab of the OP create
dialogue.

65
00:09:02,800 –> 00:09:16,500
Similar to the chop execute DAT,
the value of 0 or NULL equates
to OFF, and anything other than
0 equates to ON.

66
00:09:16,500 –> 00:09:23,533
I’m using using a special Python
snippet to reference the value
of the text string in the field.

67
00:09:23,533 –> 00:09:31,367
The operator it references is
the “out1” DAT, located inside
the field component.

68
00:09:31,367 –> 00:09:48,600
When I type new text into the
field, you’ll see the results
are monitored by the panel
execute DAT, and the changes are
processed by the various 5
methods employed by the DAT.

69
00:09:48,600 –> 00:09:58,200
If I change the value in text
field to 0, you’ll see that we
get a report that the field is
currently OFF.

70
00:09:58,200 –> 00:10:04,967
I change the value to 1, and the
field state is reported as ON.

71
00:10:04,967 –> 00:10:20,867
This technique is extremely
useful in building user
interfaces, where user actions
need to be closely monitored,
and can trigger resulting
animations or logic actions.

72
00:10:20,867 –> 00:10:27,400
The parameter execute DAT
monitors an operator’s
parameters.

73
00:10:27,400 –> 00:10:35,267
I’ve wired 2 constant CHOPs to a
switch CHOP, and we’ll monitor
the switch.

74
00:10:35,267 –> 00:10:46,400
The switch CHOP has 2 parameters
we are interested in monitoring:
the “index” parameter and the
“indexfirst” parameter.

75
00:10:46,400 –> 00:10:59,300
The parameters we wish to
monitor must be entered by name
in the parameter named
“Parameter” in the parameter
execute DAT.

76
00:10:59,300 –> 00:11:05,100
It’s a bit confusing, yes, but
very logical and powerful.

77
00:11:05,100 –> 00:11:16,633
You can always find the actual
name of the parameter by
hovering your mouse over the
entry in the parameter panel.

78
00:11:16,633 –> 00:11:30,633
The setup for this example is
similar to the previous
examples, but since we are
monitoring and accessing
parameters, pay attention to the
Python snippets I’ve used.

79
00:11:30,633 –> 00:11:40,533
The Python object named “par” is
used to access a parameter,
followed by the parameter’s
name.

80
00:11:40,533 –> 00:11:53,200
It’s important to understand the
underlying architecture and
difference between, a CHOP’s
parameters, and its channel
values.

81
00:11:53,200 –> 00:11:58,200
This example is designed to help
you see that difference.

82
00:11:58,200 –> 00:12:10,533
We can use Python expressions to
drive the “Index” parameter of
the switch CHOP, or we can use a
constant, which is an integer or
a float.

83
00:12:10,533 –> 00:12:21,200
The parameter execute DAT can
monitor the state of the “Index”
parameter, and tell us what
method we are currently using.

84
00:12:21,200 –> 00:12:34,900
If we are using expressions, we
can access the value of that
expression as an evaluation, or,
we can access the Python snippet
itself as a string.

85
00:12:34,900 –> 00:12:36,900
Since we are monitoring the
parameter named “inputfirst”, we
can also tell whether or not
that parameter is enabled.