Docs CHOPs & sensing
ConstantCHOP
A Constant CHOP with typed values: numbers, toggles, tuples, text, paths or operator references, each promoted as a property you can read and set from Python, and a snap from its input. An alternative for the Constant CHOP.
∿ CHOPs & sensing ◆ Patreon · Base OP Create menu entry
Why use it
A component's settings are seldom all numbers. Next to a speed and an amount there is a colour, a file to load, the TOP to show, a label. The numbers go in a Constant CHOP, the rest ends up spread over custom parameters and a Table DAT, and reading them back from a script means knowing which is where.
ConstantCHOP holds a list of named values, like the Constant CHOP, and gives the values a type. Numbers come out as channels, everything comes out as a table, and with one line of Python you can read or set any of them by name.
Features
- Typed constantsEvery constant can be a float, integer, toggle, four-value tuple, string, file or folder path, or operator reference.
- Channels plus a tableNumbers, toggles and tuples come out as CHOP channels, and every constant also comes out as a DAT table of names and values.
- Switch type without losing valuesChanging the type keeps each value wherever it converts.
- Snap from the inputSnap Input turns whatever is wired in into constants, one per channel, named and valued from it.
- Replace a Constant CHOPCreate a Constant CHOP with the alternatives shortcut held and ConstantCHOP is offered in its place.
- Constants as propertiesEach constant is a property that reads and sets it, a _out property reads the output, and a prefix avoids clashes.
How to use it
- Create it from the FNS tab of the OP Create dialog. Or create a Constant CHOP with the alternatives shortcut held and pick ConstantCHOP.
- Pick the Type first. It applies to every constant on the node: a float, an integer, a toggle, a four-value tuple such as XYZW or RGBA, a string, a file or folder path, or a reference to an operator. For constants of another kind, add a second ConstantCHOP.
- Add constants with the sequence's + button and give each a Name and
a Value. A new constant is named
chan1,chan2and so on until you rename it. - Read them where you need them. Numbers, toggles and tuples come out of out1 as channels; out2 holds every constant as a table of names and values, and it is the only place text, paths and references come out.
Switching Type later keeps each value wherever it converts, so floats switched to integers keep their values, rounded. A value that does not convert goes back to the default.
To start from what is already in a CHOP, wire it in and press Snap Input: the constants are replaced with one per channel, named and valued from it. Snap Input works while Type is Float or Int.
Constants as properties
With Promote to Property on, each constant is also a property on the node,
named after the constant with its first letter capitalised:
op('ConstantCHOP').Speed reads and sets the constant named speed, and
Speed_out reads what the node outputs for it.
consts = op('ConstantCHOP')
consts.Speed = 2.5 # set the constant named speed
speed = consts.Speed.eval() # the property is the Value parameter itself
out = consts.Speed_out # a channel for a single number, else its cell in out2
- Setting it does nothing while that Value is driven by an expression or an export.
- Property Prefix ships empty. If a constant's name clashes with
something already on the COMP, the node shows a script error naming it; a
prefix such as
C_turnsSpeedintoC_Speedand clears the clash.
Input and outputs
- in1 (CHOP): optional; the channels Snap Input copies from.
- out1 (CHOP): the numeric constants as channels.
- out2 (DAT): every constant as a table of names and values.
Get it
This tool unlocks with Patreon. It installs through the same picker as everything else and unlocks with the Patreon Base tier or higher, connected from inside TouchDesigner. Everything else in the toolkit stays free and MIT, and the membership is what keeps that work moving.
Where it appears
- OP Create menu entryposition 0
Parameters
Constant
| Control | Type / default | What it does |
|---|---|---|
TypeType |
menuFloat | The kind of value every constant holds. Numbers, toggles and tuples come out of the CHOP output; text, paths and operator references come out of the DAT output. Switching keeps each value where it converts. |
ConstantConstant |
sequence0 | One block per constant: add or remove blocks here. |
NameConstant0name |
textempty | The channel name, and the property name when Promote to Property is on. |
ValueConstant0value |
number0 | The constant's value. |
Common
| Control | Type / default | What it does |
|---|---|---|
Snap InputSnapinput |
button | Replace the constants with the channels wired into the input: one block per channel, named and valued from it. Float and Int only. |
Promote to PropertyPromote |
on / offon | Expose each constant as a property on this COMP, so op(...).Name reads and sets its value and Name_out reads the output. |
| To get/set values as .{prefix}{name} | ||
Property PrefixPrefix |
textC_ | Put in front of every property name, to keep them clear of other names on the COMP. |
| Author: Function Store (@function.str) | ||