I'm trying to use this custom script in C# for checking titles in a list, and setting them in the timeline one by one. This is my first time using Vegas scripts, but I'm getting errors and have tried a few different ways to fix it, but no luck ><
using System; using System.Windows.Forms; using ScriptPortal.Vegas; namespace SampleScript1 { public class EntryPoint { public void FromVegas(Vegas vegas) { // Initialize the titles array string[] titles = { "Title 1", "Title 2", "Title 3", "Title 4", "Title 5" }; // Insert the titles into the timeline int trackIndex = 0; // Target track index Timecode cursorPosition = vegas.Transport.CursorPosition; foreach (string title in titles) { cursorPosition = AddTitleAt(vegas, title, trackIndex, cursorPosition); } MessageBox.Show("Titles inserted successfully."); } private Timecode AddTitleAt(Vegas vegas, string title, int trackIndex, Timecode cursorPosition) { // Create a new video track if it doesn't exist while (vegas.Project.VideoTracks.Count <= trackIndex) { vegas.Project.AddVideoTrack(); } // Find the text generator plug-in PlugInNode plugIn = vegas.Generators.GetChildByName("Sony Titles & Text"); if (plugIn == null) { MessageBox.Show("Could not find 'Sony Titles & Text' generator."); return cursorPosition; } // Create a media object with the generator plug-in Media media = new Media(plugIn); // Set the generator preset to the title text media.Generator.Preset = title; // Create a new video event in the track VideoEvent videoEvent = vegas.Project.VideoTracks[trackIndex].AddVideoEvent(cursorPosition, new Timecode(5.0)); // Add the take using the generated video stream Take take = videoEvent.AddTake(media.GetVideoStreamByIndex(0)); return videoEvent.End; } } }
Do any of you guys see any glaring faults in the code?
Thanks so much for your help!
Connor