I am having an issue in this file that I do not understand. When I add more rows to “grid1” (other that 3 rows and 3 cols) “dateexec1” receives an error saying it cannot convert a string into a float. I am a Python newbie and cannot work my way out of this. If anyone could help, that would be wonderful. TY
Fauset_02.14.toe (6.1 KB)
Hi @realteeth,
The initial issue here is that when more rows are created, they are created empty. Now the script is looking into the empty rows and tries to convert an empty string into a number which it can’t do.
To avoid that, you can add in a if
statement, checking if the string is empty and if so either set it to 0
or 1
- depending on how it should behave:
def onCellChange(dat, cells, prev):
for cell in cells:
cellVal = out[cell.row,0]
if cellVal == '':
cellVal = 0
newValue = int(cellVal) + int(cell)
if newValue <= 255:
out[cell.row,0] = newValue
else:
out[cell.row,0] = 0
return
You could also just make use of Count and Shuffle CHOPs, avoiding scripts alltogeteher. This is then a nice way of ensuring that all channels are setup when you change the size of the grid.
Attached the example.
Fauset_02.15.toe (8.3 KB)
cheers
Markus
1 Like
Thank you! The Chop solutions really cleans this up as well.