RomeoDespres / reapy

A pythonic wrapper for REAPER's ReaScript Python API
MIT License
111 stars 25 forks source link

RPR.SetMediaItemInfo_Value() not working for project.items #90

Closed DrewTNBD closed 4 years ago

DrewTNBD commented 4 years ago

This call to RPR.SetMediaItemInfo_Value does not work when iterating over items gotten from project.items.

        with rp.inside_reaper():
            all_items = project.items
            max_group_id = [item.get_info_value('I_GROUPID') for item in all_items]
            max_group_id = int(max(max_group_id))
            selected_items = project.selected_items

            for item in selected_items:
                new_group_id = max_group_id + 1
                RPR.SetMediaItemInfo_Value(item, 'I_GROUPID', new_group_id)

If I swap the for loop for the following:

            for item in range(0, len(selected_items)):
                gotten = RPR.GetSelectedMediaItem(0, item)
                RPR.SetMediaItemInfo_Value(gotten, 'I_GROUPID', new_group_id)

Then I get the result I expect - the items I select should all be in the same group.

Levitanus commented 4 years ago

RPR.SetMediaItemInfo_Value(item.id, 'I_GROUPID', new_group_id)

DrewTNBD commented 4 years ago

Dohhhh, I'm an idiot. I didn't realise about .id.