looping through custom lists

66 viewsGeneral
0

I would really appreciate some help here.
I have created this script to highlight visible tracks. At the moment it’s divided in two reactions triggered by buttons.
One is creating a list of visible tracks – this works ok and returns the correct track numbers.
The other reaction loop through the list and is meant to update the modifiers (M1 to M8).
However all modifiers are given the same value (0).

I am using these lines to update the modifiers (please note that I have to add 1 to the loop number as it appears that custom list index is 1 and not 0):

self.set_modifier_value(“m1”, self.get_list_item(“list1”, loop_number +1))
self.set_modifier_value(“m2”, self.get_list_item(“list1”, loop_number +1))
etc

Now I would expect the loop number to increase with every iteration, but is it not?
The loop is in the same block as the action….

admin Changed status to publish May 22, 2024
0

Thank you very much John; this helped me to sort out this script!
I had to change your line as I got an error message saying that INT coulnd not be appened to a string. I chanched it like to this line :
self.set_modifier_value(“m” + str(loop_number + 1), self.get_list_item(“list1”, loop_number +1 + self.get_sessbox_track_offset()))

I also added the session box offset so that now the selction moves with the session box. I will be posting the fininshed script when done for the benefit of other users.

cheers!

admin Changed status to publish May 22, 2024
Attached Files:
0

Hi,

Are you referring to the reaction named “update modifiers” in your attached script?
If so, you’re setting all of the modifiers to the same value with each loop iteration.

You should have 1 action and update the modifier name each time:
self.set_modifier_value(“m” + loop_number, self.get_list_item(“list1”, loop_number +1))
However, you may run into errors if you try to save to modifiers greater than m20, so I’d recommend add a condition in which checks that the loop number is less than or equal to 20.

admin Changed status to publish May 22, 2024
Attached Files: