Comments

jetdv wrote on 2/9/2009, 6:32 AM
A script can easily add a text generated media but it cannot change the actual text. Is that good enough?
JohnnyRed wrote on 2/9/2009, 1:20 PM
Yes, all I want is a script to insert the text media events. I figured I would have to set the text for each event, and that is fine with me.

Thanks for your help.
jetdv wrote on 2/9/2009, 1:32 PM
This will work for you:

 
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.
JohnnyRed wrote on 2/9/2009, 8:52 PM
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.
jetdv wrote on 2/10/2009, 6:03 AM
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.

Blur Studio wrote on 3/17/2009, 3:25 PM
Hello Sony ;)

Any ETA on when we might get scripting access to the text ? (add me to the list of people who would want it :D)

krash
Blur Studio, Inc.