How to set Constant CHOP's channel count

Is there a way to set the Constant CHOP’s channel count with Python? I want to make sure that the created channel count matches the size of a particular DAT (the DAT contains channel names in a single column). I can programmatically iterate through my DAT and set the constant CHOP’s channel names accordingly (e.g. op('constant1').par.const0name etc.). But if the DAT size shrinks, I then have a surplus of channels. I tried op('constant1').par.size = 16 but that didn’t seem to do anything.

Why not just use the DAT to CHOP to convert the table into a CHOP?

Yes, a DAT to CHOP would give me the correct channel count, but not channel names. After that I’d need to rename all the channels to be meaningful. I dug through the Rename CHOPs docs a bit more and realized I could write the channel name list into the ‘To’ field on the Rename CHOP.

The kicker is that downstream I pulse the channels themselves. Afaik for that I need a Constant CHOP. Yes, I could pulse the snapshot-input parameter which would reset the contents of the Constant CHOP to adopt the correct names and channel count.

So DatTo CHOP → Rename CHOP → Constant CHOP, or just set the channel count of the Constant CHOP while I update all the names and values.

Yes, a DAT to CHOP would give me the correct channel count, but not channel names.

I’m confused, you said you had the channel names in a column, which should “just work” if you set “first column is names” on the DAT to CHOP. I think you are trying to fit the Constant CHOP into a pattern it isn’t intended for, but glad you found something that works for you.

This is how you can set the number of channels.

@whorl I actually don’t have channel names, I have a channel group heading, e.g. KnobA, and then there are x lines of information, so the resulting names I need would be KnobA1..KnobA8, KnobB1…KnobB8, etc.

@aaronmylespereira Yes, that worked, thank you! But wow, how completely non-obvious a solution is that?!? And what the heck is the name0 par, it doesn’t come up on a list when aiming a Parameter DAT onto the Constant CHOP to inspect its parameter list, but when I

dir(op(‘const1’).par.name0)

it it says it’s actually const0name. I’m guessing that the Constant CHOP has some legacy – I found this post:

which also is about the Constant CHOP.

Hi @antoinedurr,

the described way is to get to a sequence via a parameter. Similar to finding the operator a parameter belongs to via the .owner member.

You can also get directly via the sequence name to the sequence object:

# get to the const sequence of the Constant CHOP
constSeq = op('constant1').seq.const
# set the number of blocks in the sequence
constSeq.numBlocks = 10

cheers
Markus

I admit I’m not familiar with the notion of the parameter sequence in TD – in Houdini you can make a multiparm folder, and the multiparm count is the value of the folder, so if you want 5 sets of the parameters, you’d so something like node.parm(‘constants’).set(5). One thing I’ve noticed is that zero doesn’t seem to be a valid length for TD parameter sequences, there’s at least always one.

Hi @antoinedurr

pretty similar in TouchDesigner with the noted difference that there is always at least one block.
For length, you can either go via .numBlocks for a get/set, or call len() on the sequence itself.

An overview of Sequential Parameters in TouchDesigner can be found here:

cheers
Markus