Is there a script to insert text media events just before each video clip that I have on my timeline? I like to have a short introductory text prior to each clip and it seems like there should be a clip to do this.
PlugInNode generator = myVegas.Generators.GetChildByName("Sony Text");
media = new Media(generator, "PresetNameThatYouWantToUse");
stream = media.Streams[0];
newEvent = new VideoEvent(myVegas.Transport.CursorPosition, evLen);
myVegas.Project.Tracks[0].Events.Add(newEvent);
take = new Take(stream);
newEvent.Takes.Add(take);
It adds the event at the cursor location so change the position as needed in the 4th line. Also, set the preset you want to use in the second line. Also, it specificly uses the first track in line 5 (Tracks[0]) so you'll need to change that to reference the proper track. Otherwise, you should be able to use the code above straight.
Thank you so much for the script. Will this add just one text media event or will it add one prior to each clip on the timeline? That's what I was aiming for - so if I had 10 clips on the timeline, the script would add a text media event prior to each of the ten clips just by running the script one time. If that is too complicated, the script you offered will still save time, I was just looking for a way to automate the process even more.
The code above would simply add a single text event at the cursor location. You would add it to your code in a loop to add for each event. This code is untested but is the basis for adding a text event at each event:
using System;
using System.Windows.Forms;
using Sony.Vegas;
public class EntryPoint
{
Vegas myVegas;
public void FromVegas(Vegas vegas)
{
myVegas = vegas;
Track titleTrack = new VideoTrack(0, "Titles");
myVegas.Project.Tracks.Add(titleTrack);
foreach (Track track in myVegas.Project.Tracks)
{
if (track.Selected)
{
foreach(TrackEvent evnt in track.Events)
{
PlugInNode generator = myVegas.Generators.GetChildByName("Sony Text");
media = new Media(generator, "Default Text");
stream = media.Streams[0];
newEvent = new VideoEvent(evnt.Start, evLen);
titleTrack.Events.Add(newEvent);
take = new Take(stream);
newEvent.Takes.Add(take);
}
}
}
}
}
As mentioned, this is UNTESTED so there may be an error or two but it does have the basics. Save it as something like "AddTitles.cs" and try it. It will add a new "title" track as the top track and then add titles for all events on SELECTED tracks.