How to move channel names with values greater than zero to Text TOP?

Hello,

I am new to Touchdesigner, and I would like to know if anyone can help me resolve a question that I am unable to answer…

In a list of CHOP channels, I want to extract only the names of channels that have a value greater than zero and display them in the text parameter of a TOP. In the case of the attached photo, the Text TOP should print ‘cs’ and ‘d’.

I am trying to do this with a CHOP execute, but I can’t get those values to pass to the Text TOP.

I would really appreciate it if someone could help me.

Thank you!

chopToText.toe (3.9 KB)

def onValueChange(channel: Channel, sampleIndex: int, val: float, prev: float):
    c = op(‘constant1’)
    result = ‘’
    for i in range (0,c.numChans):	
        if i == 0:
            if c[i] != 0:
                result += c[i].name
        else:
            if c[i] != 0:	
                result += ‘,’ + c[i].name
    op(‘text1’).par.text = result
    return

Thank you Markus for the re-formating.

I had copy problems with my old Mac/Firefox

1 Like