Parent/Child Track with ReorderSelectedTracks
Closed this issue · 3 comments
manchuwook commented
Given:
import argparse
import sys
import logging
import random
import math
import reapy
from colors import randColorByHue
from reapy import reascript_api as RPR
def makeTracks(project):
tracks = ['Chords - Scratch', 'Chords', 'Arpeggio', 'Bass', 'Sub', 'Pad',
'Lead', 'FX1', 'FX2', 'FX3', 'Rhythmic', 'Percussion', 'Harmony', 'Melody']
tracks.reverse()
for track in tracks:
t = project.add_track(name=track)
t.color = randColorByHue('red')
if track == 'Melody':
t.add_fx(name='Captain Melody')
if track == 'Bass':
t.add_fx(name='Captain Deep')
if track == 'Arpeggio':
t.add_fx(name='ChordPotion')
t.add_fx(name='ReaSynth')
if track == 'Chords - Scratch':
t.add_fx(name='Captain Chords')
t.add_send(destination=project.tracks['Chords'])
t.add_send(destination=project.tracks['Arpeggio'])
for track in project.tracks:
if track.name == 'Chords - Scratch':
track.select()
# Fetch the index for scratch
RPR.ReorderSelectedTracks(1, 1)
ReorderSelectedTracks doesn't seem to make the track 'Chords - Scratch' a child of parent track 'Chords'
Is there some kind of magic I am missing, or is this not implemented yet?
Levitanus commented
It definitely works within just line:
RPR.ReorderSelectedTracks(1, 1)
So, only thing you need is
# Fetch the index for scratch
Which can be made by:
for idx, track in enumerate(project.tracks):
if track.name == 'Chords - Scratch':
track.select()
RPR.ReorderSelectedTracks(idx, 1)
Which, still, works quite fine within my project and my track name
Levitanus commented
But this, occasionally, showed that API is needed Track.index property, which is included in #77
manchuwook commented
Thanks!