I'd like to write a script that lines up some clips that are on multiple tracks. But I am stuck on moving a clip (event) from one track to another. Does anyone have an example of how this is done?
See if this gets you going on the right track... It will move all selected events to the "next track down". Of course, you'll need to modify this to suit your needs plus, it "assumes" there is a track below it where the new event can be placed - in other words, it doesn't check to see if it "can't" work.
Also, to do this you set the event track to the new track. Please see my tutorials to see whey we are counting backwards through the events and the pitfalls of just removing events from a track:
using System;
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Drawing;
using System.Runtime;
using System.Xml;
using ScriptPortal.Vegas;
namespace Test_Script
{
public class Class1
{
public Vegas myVegas;
public void Main(Vegas vegas)
{
myVegas = vegas;
foreach (Track myTrack in myVegas.Project.Tracks)
{
if (myTrack.IsVideo())
{
for (int i=myTrack.Events.Count - 1; i>=0; i--)
{
TrackEvent evnt = myTrack.Events[i];
if (evnt.Selected)
{
evnt.Track = myVegas.Project.Tracks[evnt.Track.Index + 1];
evnt.Selected = false;
}
}
}
}
}
}
}
public class EntryPoint
{
public void FromVegas(Vegas vegas)
{
Test_Script.Class1 test = new Test_Script.Class1();
test.Main(vegas);
}
}
In this case, we simply set the track to the destination track (which is the "next" track) and the start time remains the same so it will go straight down. Then, because I'm doing every selected event, that moved event is still selected so I deselect it.
What would I do without you Jetdv? Just what I needed. One minor follow-up question - could I use a track's name to determine the destination. Is there a method such as myTrack = myVegasProject.Tracks.Name("Label")?