To convert the provided parameter execute script to a CHOP execute script in TouchDesigner, you need to adapt the code to work with CHOP channels instead of parameters. The key difference is that the CHOP execute script will be triggered by changes in the CHOP channel values rather than parameter changes.
Here is how you can modify the script:
- Change the function signature to match CHOP execute script:
- Use
onValueChange(channel, sampleIndex, val, prev) as the function signature.
- Replace parameter references with channel references:
- Access the channel values instead of parameter values.
Here’s the updated script:
def onValueChange(channel, sampleIndex, val, prev):
text_top = op('/project1/base1/TYPOGRAPHY_V2/arranging_text/text4')
print("Error: Could not find Text TOP at /project1/base1/TYPOGRAPHY_V2/arranging_text/text4")
# Get the text parameter from the Text TOP
text_content = text_top.par.text.eval()
text_dat = op('/project1/base1/TYPOGRAPHY_V2/arranging_text/text1')
print("Error: Could not find Text DAT at /project1/base1/TYPOGRAPHY_V2/arranging_text/text1")
# Set the content of the Text DAT
text_dat.text = text_content
print("Text DAT updated with content from Text TOP")
-
Function Signature:
def onValueChange(channel, sampleIndex, val, prev): replaces the parameter execute function signature.
-
Channel Handling:
- The function signature now includes
channel, sampleIndex, val, prev, which are the arguments passed by the CHOP execute DAT.
-
Checking for Errors:
- The script includes checks to ensure the required operators (
Text TOP and Text DAT) exist before attempting to access or modify them.
-
Updating Text DAT:
- The content of the
Text DAT is updated with the evaluated text from the Text TOP.
This updated script should work within a CHOP execute DAT, responding to changes in the specified CHOP channels and updating the Text DAT accordingly.