Replicator COMP

From TouchDesigner 099 Wiki

Summary

The Replicator Component creates a node for every row of a table, creating nodes ("replicants") and deleting them as the table changes. A node can be a full component and its contents.

It takes the node specified in the Master Node parameter, and for every row in the Template Table, makes a copy of the master.

The nodes that are created can be named in two ways. Copies can be named/numbered sequentially using the prefix specified by the Node Prefix parameter: item1, item2, ... Alternately, copies can be named based on the string in a column of the table, specified with the Name from Table parameter.

Replicator.1.png

If you want to create a node for the first row of the table, un-set the Ignore First Row parameter.

The replicants get laid out in a grid in the network, determined by the Layout and Layout Origin parameters.

The Replicator does not assume or require that the master and replicants are components – they can all be Movie File In TOPs if you want. It also does not assume or require that the replicants are clones. However the Master Node can be a component whose Clone parameter is set to itself, so that all nodes created are clones of the master.

For every replicant, you can run a script in the callback DAT where you can see some examples of typical cases that you can adapt. Here are some others:

  • change the expression of a parameter: c.par.display.expr = "op('thing')[op.digits, 'display']"
  • Change the parameter expression mode: c.par.display.mode = ParMode.EXPRESSION The mode is one of: ParMode.CONSTANT, ParMode.EXPRESSION, or ParMode.EXPORT.

If only one line of a table changes, the other existing replicants are not changed or re-created.

This is an extremely powerful node type. Examples: a button gadget for each row of the table. a geometry component, which is replicated at every point of a 3D particle system, each behaving separately. You can feed the table of a Multi Touch In DAT directly to the Replicator to create something at each fingertip.

PythonIcon.png replicatorCOMP_Class

Example Files : see examples in the OP Snippets

Parameters - Replicator Page

Template Table /template - Path to the table DAT that will drive the replicating.

Name from Table /namefromtable - How the node names will be generated.

  • Row Index: Uses the Node Prefix parameter followed by the row number. The default creates nodes named item1, item2, item3 .... (The top row is 0).
  • Column by Index: The node name is in the column specified by a column number.
  • Column by Name: The node name is in a column specified by a column name in the first row.

Ignore First Row /ignorefirstrow - Do not create a node for the first row.

Column Name /colname - Name at the top of the column.

Column Index /colindex - Column number, starting from 0.

Node Prefix /nodeprefix - Add this prefix to all nodes.

Master Node /master - Which node or component to replicate.

Location /location - Where to put the replicant nodes. If the location is .., it puts the nodes inside the parent, which is actually alongside the Replicator component. If you put ., it will put it inside itself, that is, inside the Replicator component. If left blank, it will error.

Maximum Nodes /maxnodes - Max number of nodes, to keep it under control.

Script /script - Tscript only (use callback DAT in python): For every replicant, you can run a script to customize it relative to the master, such as setting the Display or Clone parameters, or a Render flag. Replicator runs the script command to customize each replicant versus the master. me.curItem can be used here to access the current item and make changes to it. Select one of the 3 entries in the drop menu to the right for some examples.

If you are using Tscript, some local variables are defined:

  • $ITEM Name of current node being replicated.
  • $MASTER Name of master node.
  • $LOCATION Name of the location component.

The most common need is for the master to not display, and the replicants to display. For Panel components it is most commonly "opparm $ITEM paneldisplay ( 1 )", and for Geometry components it is most commonly "opset -d on $ITEM". Use the popup menu for some common scripts.

Callbacks DAT/callbacks - Path to a DAT containing callbacks for each event received. See replicatorCOMP_Class for usage.

Layout /layout - How to lay out the new nodes - all in one place (Off), horizontally, vertically, or in a grid.

Layout Origin /layoutorigin1, layoutorigin2 - Where to lay out the new nodes, giving the XY location of the top-left node's bottom-left corner.

Re-create All Nodes /recreateall - Deletes all nodes it has created, then re-creates them using the template and its current parameters.

Parameters - Common Page

Node View /tileview - what is displayed in the Node Viewer.

  • Network Viewer - displays the component's internal network in the viewer.
  • Parameters - displays the component's parameters in the viewer.
  • Operator Viewer - displays the viewer of the operator referenced in the Operator Viewer parameter below.

Operator Viewer /opviewer - path to the operator used when the Node View parameter is set to Operator Viewer.

Clone /clone - path to a Master Clone for this component.

Path Variable /pathvar - set the name of a Path Variable for this component.