Tag Archives: text

Nov 12 2014

Sort DAT tutorial.

The Sort DAT. TouchDesigner 088. 2014.
The Sort DAT allows you to re-arrange rows and columns in tables based on specific criteria.

1
00:00:00,533 –> 00:00:03,467
Let’s examine the sort DAT.

2
00:00:03,467 –> 00:00:09,633
The sort DAT will sort incoming
table DAT entries by row or by
column.

3
00:00:09,633 –> 00:00:17,633
Remember, we can click the
“edit” button in the table DAT
parameters to launch our default
text editor.

4
00:00:17,633 –> 00:00:21,967
We wire our table DAT to a sort
DAT.

5
00:00:21,967 –> 00:00:26,300
In the sort DAT, we must choose
use a sort method.

6
00:00:26,300 –> 00:00:35,567
Here we will sort our rows, and
we specify a column index of
0 because we only have one
column.

7
00:00:35,567 –> 00:00:37,400

8
00:00:37,400 –> 00:00:41,867
We choose to order our incoming
data alphabetically.

9
00:00:41,867 –> 00:00:45,067

10
00:00:45,067 –> 00:00:49,967
Let’s look at some more
complicated sorting methods.

11
00:00:49,967 –> 00:00:55,833
Here we sort our rows, but we
change our column index to 1.

12
00:00:55,833 –> 00:01:06,667
Since our columns are indexed on
a base 0 numbering system, we
are now sorting the numerical
entries in the second column.

13
00:01:06,667 –> 00:01:15,267
The sorted values now step
numerically- 8, 9, 20, 22 and
77.

14
00:01:15,267 –> 00:01:20,100
Now we sort column index 2,
which is our third column.

15
00:01:20,100 –> 00:01:21,400

16
00:01:21,400 –> 00:01:28,500
Our row entries now step 3, 6,
6, 8 and 66.

17
00:01:28,500 –> 00:01:29,700

18
00:01:29,700 –> 00:01:35,500
In this example we will sort our
incoming table DAT entries by
column.

19
00:01:35,500 –> 00:01:36,500

20
00:01:36,500 –> 00:01:41,700
We turn on the “preserve first”
option in the parameters panel.

21
00:01:41,700 –> 00:01:51,100
This allows our first column, in
this case our row identification
entries, to retain their
original order.

22
00:01:51,100 –> 00:01:52,600

23
00:01:52,600 –> 00:02:02,033
If we specify a row index of 0,
we will sort our columns based
on the values in the first row.

24
00:02:02,033 –> 00:02:12,500
The columns that begin with the
values 22, 3, and 7, are now
re-ordered into 3, 7, 22.

25
00:02:12,500 –> 00:02:14,967

26
00:02:14,967 –> 00:02:19,533
Let’s change to specify row
index 1.

27
00:02:19,533 –> 00:02:24,733
Now we re-sort our columns based
on the entries in the second
row.

28
00:02:24,733 –> 00:02:26,300

29
00:02:26,300 –> 00:02:31,500
The sort DAT is a simple but
very effective way to
restructure table data.

30
00:02:31,500 –> 00:02:33,500

Posted In
Tagged
Nov 12 2014

Insert DAT tutorial.

The Insert DAT. TouchDesigner 088. 2014.
The Insert DAT is a handy and flexible Operator. Manipulating and re-formatting tables is a common practice; the Insert DAT can help you make targeted changes to DAT networks.

1
00:00:00,800 –> 00:00:04,200
Let’s examine the insert DAT.

2
00:00:04,200 –> 00:00:06,933
We start with a table DAT.

3
00:00:06,933 –> 00:00:20,367
It’s important to remember that
by clicking the “viewer active”
tab on the bottom right we can
edit the contents of our table
DAT directly in the node.

4
00:00:20,367 –> 00:00:30,733
We can also press the “edit”
button in the table DAT
parameters to launch our default
text editor.

5
00:00:30,733 –> 00:00:39,233
Changes we make in the text
editor will be saved in the
table DAT.

6
00:00:39,233 –> 00:00:42,533

7
00:00:42,533 –> 00:00:48,367
We wire the table DAT to an
insert DAT.

8
00:00:48,367 –> 00:00:50,533

9
00:00:50,533 –> 00:00:56,367
We choose to insert a column
before the first column.

10
00:00:56,367 –> 00:00:58,700

11
00:00:58,700 –> 00:01:08,133
In the contents field we type in
the text strings we would like
to add to the new table.

12
00:01:08,133 –> 00:01:14,333
We’ve separated each addition of
new text with a space.

13
00:01:14,333 –> 00:01:22,600
This automatically separates the
new text content into a new row.

14
00:01:22,600 –> 00:01:28,233
Each character grouping
separated by a space will be-
come a new row.

15
00:01:28,233 –> 00:01:37,300
The insert DAT will
automatically adjust for
leftover rows by creating blank
cells.

16
00:01:37,300 –> 00:01:45,667
We can use any text strings we
like to create new row content.

17
00:01:45,667 –> 00:01:51,200

18
00:01:51,200 –> 00:02:06,500
For this example, instead of
manually entering our character
groupings, we will use Python to
create an automatic row
insertion.

19
00:02:06,500 –> 00:02:09,133
Let’s examine this Python
expression.

20
00:02:09,133 –> 00:02:14,000
We’ll use the “string join”
Python method.

21
00:02:14,000 –> 00:02:22,633
In a “for loop”, we will iterate
over the incoming number of
table rows.

22
00:02:22,633 –> 00:02:32,967
For each table row, we will
create a string consisting of a
header and the number of that
row.

23
00:02:32,967 –> 00:02:42,433
The table DAT named “table3” is
referenced as me.inputs[0].

24
00:02:42,433 –> 00:02:48,700
It contains 8 rows numbered from
0 to 7.

25
00:02:48,700 –> 00:02:53,500

26
00:02:53,500 –> 00:03:03,633
The header is the first part of
our string, which we can change
to any character sequence we
like.

27
00:03:03,633 –> 00:03:07,733

28
00:03:07,733 –> 00:03:15,000
And the numerical value of the
row count is the second part of
our string.

29
00:03:15,000 –> 00:03:16,233

30
00:03:16,233 –> 00:03:23,167
Again, we count through the
number of rows from 0 to 7.

31
00:03:23,167 –> 00:03:34,500
I’ve included two links to help
you learn more about the Python
“join” method, and Python list
comprehensions.

32
00:03:34,500 –> 00:03:36,500

Nov 12 2014

Convert DAT tutorial.

The Convert DAT. TouchDesigner 088. 2014.
The Convert DAT is used to format text and strings in a DAT network.

1
00:00:01,267 –> 00:00:03,900
Let’s examine the convert DAT.

2
00:00:03,900 –> 00:00:07,800
We have an example here with two
convert DATs.

3
00:00:07,800 –> 00:00:11,267
We start with a text DAT.

4
00:00:11,267 –> 00:00:30,567
It’s important to know we can
alter the contents of our text
DAT by pressing the “viewer
active” button on the bottom
right of the operator, and
typing directly in the text DAT
contents.

5
00:00:30,567 –> 00:00:41,300
We wire the text DAT to a
convert DAT and choose the “How”
method of converting to a table.

6
00:00:41,300 –> 00:00:43,967
Let’s look at the “split cells”
option.

7
00:00:43,967 –> 00:00:52,300
This is the character that Touch
Designer will use to convert our
incoming text into table cells.

8
00:00:52,300 –> 00:01:03,733
We can separate multiple
characters with a space to
create a list, or array, of
characters to use as split cell
indicators.

9
00:01:03,733 –> 00:01:05,333

10
00:01:05,333 –> 00:01:11,500
In this example we wire another
text DAT to a convert DAT.

11
00:01:11,500 –> 00:01:24,367
We have another option for
editing contents of a text DAT,
which is to press the “edit”
button on the parameters
options, which will launch our
default text editor.

12
00:01:24,367 –> 00:01:36,267
We can type changes in our text
editor, and then save the
changes, that will automatically
update in the Touch Designer
text DAT.

13
00:01:36,267 –> 00:01:40,267

14
00:01:40,267 –> 00:01:52,500
Here we use a simple Python
expression to create the
character we wish to use as our
split cell value.

15
00:01:52,500 –> 00:01:57,700
This network begins with a
slider.

16
00:01:57,700 –> 00:02:03,600
The slider outputs an initial
value of 0 to 1.

17
00:02:03,600 –> 00:02:12,633
We wire the slider to a null
CHOP to see this initial value.

18
00:02:12,633 –> 00:02:20,700
We then use a math CHOP to
re-range this initial floating
point value.

19
00:02:20,700 –> 00:02:27,600
First we convert our floating
point value to an integer.

20
00:02:27,600 –> 00:02:34,900
We use the round option to round
our floating point to the
nearest integer.

21
00:02:34,900 –> 00:02:43,433
Then we re-range the 0 to 1
incoming values to a range of 1
to 9.

22
00:02:43,433 –> 00:02:44,900

23
00:02:44,900 –> 00:02:51,000
We need to create a character to
use as our split cell value.

24
00:02:51,000 –> 00:03:00,833
The content of our text DAT is a
series of characters ranging
from 1 to 9.

25
00:03:00,833 –> 00:03:06,867
Let’s examine the Python
expression we’ll use to create
our split cell value.

26
00:03:06,867 –> 00:03:15,600
First we name the operator we
wish to reference, in this case
the “math1” CHOP.

27
00:03:15,600 –> 00:03:25,600
Next we name the channel, in
this case “v1”, and third we
evaluate that channel.

28
00:03:25,600 –> 00:03:41,333
Our Python expression is
complete, and as our slider
changes the value generated by
our Python expression will
update dynamically.

29
00:03:41,333 –> 00:03:49,533
We are also using the “remove
blank lines” option of the
convert DAT.

30
00:03:49,533 –> 00:03:56,900
This removes the empty cells
created by gaps in our incoming
text DAT.

31
00:03:56,900 –> 00:04:00,567

32
00:04:00,567 –> 00:04:08,033
We’ve added a third convert DAT
to convert our incoming table
back to text.

33
00:04:08,033 –> 00:04:10,500

34
00:04:10,500 –> 00:04:14,400
Let’s look at the “concatenate
with” parameter.

35
00:04:14,400 –> 00:04:21,567
This is the character that will
join the incoming table cells
into a single line of text.

36
00:04:21,567 –> 00:04:34,433
Here we are using a simple space
to create a gap, or multiple
spaces to create a gap.

37
00:04:34,433 –> 00:04:42,000
We can use any characters we
like to join the resulting text
strings.

38
00:04:42,000 –> 00:04:44,000