View Single Post
Old 10-13-2013, 06:32 AM   #21
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Sexan View Post
Hi! All new send tracks are in folder, all sends are "child"
I hope I understood correctly:


Code:
# Create send-track(s) from selected track(s) -> put new track(s) into a folder as "child track"
# and disable master/parent send for selected (sending) tracks

from sws_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0, message, -1)

with undoable("Create send-tracks from selected tracks"):

    def msg(m):
        RPR_ShowConsoleMsg(m)

    trackCount = RPR_CountSelectedTracks(0)
    if trackCount > 0:
        for i in range(trackCount):
            sourceTrackId = RPR_GetSelectedTrack(0, i)
            sourceTrackIndex = int(RPR_GetMediaTrackInfo_Value(sourceTrackId, "IP_TRACKNUMBER") - 1)
            name = RPR_GetSetMediaTrackInfo_String(sourceTrackId, "P_NAME", "", 0)[3]
            RPR_SetMediaTrackInfo_Value(sourceTrackId, "I_FOLDERDEPTH", 1.0)

            newTrackIndex = sourceTrackIndex + 1
            RPR_InsertTrackAtIndex(newTrackIndex, 1)
            receiveTrackId = RPR_GetTrack(0, newTrackIndex)
            RPR_GetSetMediaTrackInfo_String(receiveTrackId, "P_NAME", name + str(" SEND"), 1)
            RPR_SetMediaTrackInfo_Value(receiveTrackId, "I_FOLDERDEPTH", -1.0)

            # disable master/parent send for selected (sending) tracks
            RPR_SetMediaTrackInfo_Value(sourceTrackId, "B_MAINSEND", 0)

            a = SNM_AddReceive(sourceTrackId, receiveTrackId, -1) # -1=Default type (user preferences), 0=Post-Fader (Post-Pan), 1=Pre-FX, 2=deprecated, 3=Pre-Fader (Post-FX)
            if a == 0:
                msg("Absolutely nothing happened (nothing updated")
            # remove next 2 lines to set new tracks to default color
            else:
                RPR_SetTrackColor(receiveTrackId, 0x00FFCC00)   # color = 0x00BBGGRR

    # update view
    RPR_TrackList_AdjustWindows(False)
    RPR_UpdateArrange()
spk77 is offline   Reply With Quote