create child track script - need your help
hi guys,
i was about to create a python script to automatically create a new track as child of the selected track. thought it would be easy but i'm stuck so i need your help.
below is what i've done so far:
# get the selected track and its depth
# depth: 0=normal [i.e. doesn't have children & is not last], 1=track is a folder parent, -1=track is the last in the innermost folder, -2=track is the last in the innermost and next-innermost folders, etc
selectedTrack = RPR_GetSelectedTrack(0, 0)
depth = RPR_GetMediaTrackInfo_Value(selectedTrack, "I_FOLDERDEPTH")
# this creates the track AFTER the selected track
RPR_InsertTrackAtIndex(<index of selectedTrack>, True)
# if the selected track was already a folder then we're done already
# but if it was not a folder:
if depth != 1:
# make the selected track to be a folder
RPR_SetMediaTrackInfo_Value(selectedTrack, "I_FOLDERDEPTH", 1)
# and make the new track to be the last in folder - set it to minus something
RPR_SetMediaTrackInfo_Value(newTrack, "I_FOLDERDEPTH", <-???>)
So, the problem lies on the last line, how should i compute the value for the folder depth of the new track so the script can support inserting at any level? if i hardcode it to "-1" the script will only support one level deep.
also i think i don't understand how the values for the last tracks in folder are set. take for example the screenshot i attach. although tracks C & E are in the same visual depth, track "C" has I_FOLDERDEPTH=-1 while track "E" has I_FOLDERDEPTH=-2 which seems odd to me.
thanks for the help.
|