The error you’re encountering, “NoneType object is not subscriptable,” suggests that op('select1') is not returning a valid CHOP reference. This might be due to an incorrect operator path or the CHOP not being properly set up.
Let’s go through the steps to ensure everything is correctly set up:
-
Verify the Select CHOP Setup:
- Ensure that the
Select CHOP is correctly pointing to the Timer CHOP’s cycle count channel.
- Name the
Select CHOP as select1 or update the script accordingly if it’s named differently.
-
Check the Cycle Count Channel:
- Make sure that the
Select CHOP is correctly extracting the cycle count channel from the Timer CHOP.
Here’s a detailed setup guide:
-
Add a Timer CHOP:
- Ensure the Timer CHOP is configured to cycle and output the cycle count.
- Check
Output Cycle and ensure Cycle Pulse is enabled.
-
Add a Select CHOP:
- Add a
Select CHOP to your network.
- In the
Select CHOP parameters, set the CHOP parameter to the Timer CHOP and the Channel Name parameter to the cycle count channel (usually something like cycle).
-
Check the Select CHOP Output:
- Ensure that the
Select CHOP is displaying the cycle count correctly.
-
Modify the Script in CHOP Execute DAT:
Here is the updated script with additional checks to ensure that the Select CHOP is correctly referenced:
def onOffToOn(channel, sampleIndex, val, prev):
print("Function triggered")
# Get the current cycle count from the Select CHOP
select_chop = op('select1')
print("Error: Select CHOP not found")
if len(select_chop.chans()) == 0:
print("Error: No channels in Select CHOP")
cycle_count = int(select_chop[0])
print("Cycle count:", cycle_count)
# Get the list of fonts from the Table DAT
font_table = op('fontTable')
print("Error: fontTable DAT not found")
num_fonts = font_table.numRows
print("Number of fonts:", num_fonts)
# Calculate the font index based on the cycle count
font_index = cycle_count % num_fonts
print("Font index:", font_index)
# Get the font name from the Table DAT
font_name = font_table[font_index, 0].val
print("Font name:", font_name)
# Set the font of the Text TOP
print("Error: text1 TOP not found")
text_top.par.font = font_name
print("Font set to:", font_name)
-
Select CHOP Verification:
- The script now checks if the
Select CHOP is found and has channels before attempting to access its values.
-
Additional Checks:
- The script includes checks for the
fontTable and text1 operators to ensure they are correctly referenced.
-
Cycle Count Retrieval:
select_chop[0] is used to get the cycle count, and the script verifies this by printing the cycle count.
-
Ensure Timer is Running:
- Verify that the Timer CHOP is configured correctly to cycle and increment the cycle count.
-
Check Console Output:
- Run the Timer and observe the console output for the debug messages.
- Ensure the Select CHOP correctly outputs the cycle count and the script runs without errors.
By following these steps, you should be able to identify any issues with the Select CHOP setup and ensure the font index is correctly updated with each cycle of the Timer CHOP.