It's not particularly pretty, but here's a Python script ...
Edit - updated:
- prevent error when context is items but no items are selected
- when context is envelope lane show alert if script can't deal with as many env points as are in the selected lane
- when context is envelope and no points are selected, do nothing instead of locating to last point
Edit - update 2:
- if all envelope points in a lane are selected, go to the second point not the first, as it's perpetually at the project start
- made max_len 1000000 just for the heck of it
Code:
import shlex
# ------------
# locate_start_of_selection.py
# - if items are selected, move edit cursor to start of first selected item
# - if envelope is selected, move edit cursor to first selected point
# Should work with a lot of envelope points, if not just increase the value of max_len
# ------------
def msg(m):
RPR_ShowConsoleMsg(str(m) + "\n")
def cursor_to_start_of_first_sel_item():
pos_list = [ ]
num_items = RPR_CountSelectedMediaItems(0)
if num_items > 0:
i = 0
for i in range(0, num_items):
item = RPR_GetSelectedMediaItem(0, i)
pos = RPR_GetMediaItemInfo_Value(item, "D_POSITION")
pos_list.append(pos)
i += 1
pos_list.sort()
RPR_SetEditCurPos2(0, pos_list[0], 1, 0)
def cursor_to_first_sel_env_point():
try:
sel_env = RPR_GetSelectedTrackEnvelope(0)
env_chunk = RPR_GetSetEnvelopeState2(sel_env, "", max_len, 0)
split_1 = env_chunk[2].split("1\nPT")
split_2 = split_1[1].split("PT")
length = len(split_2)
first_sel_point = split_2[length - 1]
first_sel_point_list = shlex.split(first_sel_point)
first_sel_point_pos = float(first_sel_point_list[0])
if first_sel_point_list[3] == "0":
if first_sel_point_pos == 0:
second_sel_point = split_1[2]
second_sel_point_list = shlex.split(second_sel_point)
second_sel_point_pos = float(second_sel_point_list[0])
RPR_SetEditCurPos2(0, second_sel_point_pos, 1, 0)
else:
RPR_SetEditCurPos2(0, first_sel_point_pos, 1, 0)
except IndexError:
RPR_MB("Script unable to cope with so many envelope points!"
"Increase the value of \"max_len\" and try again.", "Oops!", 0)
# ------------
max_len = 1000000
context = RPR_GetCursorContext()
if context == 1:
cursor_to_start_of_first_sel_item()
elif context == 2:
cursor_to_first_sel_env_point()
This is just to keep us ticking over til a native action btw - not trying to undermine the FR! Native is best