using the CHOP EXECUTE DAT node - VALUE CHANGE

 Will make other posts as I learn how to use the other bits!

use case - say you have a Count CHOP and wish to execute a set of instructions everytime the value changes, the CHOP Execute DAT node is what you want! Eg, take values from a NOISE and apply them to a TRANSFORM, everytime the Count changes value. This is a bit like sample/hold of random values.

Create the CHOP EXECUTE DAT. Next type in the name of your Count node in the CHOPs box

The part we're interested in is this segment of code-

def onValueChange(channel, sampleIndex, val, prev):
    return
We can delete everything above that! Also make sure on the Chop Execute, that "Value Change" is set to ON.

so after the colon, we can make some variables (this is for clarity, not necessary)

def onValueChange(channel, sampleIndex, val, prev):
    
    source=op('NOISE')
    target=op('TRANSFORM')
        
    target.par.tx=source[0]
    target.par.ty=source[1]
        
    
    return
   
we're making a variable called source, and assigning our NOISE node to it. we're also making a variable called target and assigning the TRANSFORM node to it. Then we assign the tx parameter of our target (TRANSFORM) the value of our NOISE's first channel (in this case tx)...and again with the 2nd.

This is called every single time the Count Chop changes value. Neat eh.

Comments

Popular posts from this blog

Rollover effect, panel chop, image selector, containers, dat execute, panel execute, strings, ifs, renderpick and instances