I wrote the following script for one of my editor friends.
using System.Collections.Generic; using ScriptPortal.Vegas; using System.Windows.Forms; public class EntryPoint { public void FromVegas(Vegas vegas) { Dictionary<Timecode, Timecode> timecodes = new Dictionary<Timecode, Timecode>(); Timecode lastStart = null; foreach (Marker marker in vegas.Project.Markers) { if (marker.Label == "Start") { lastStart = marker.Position; } else if (marker.Label == "End") { timecodes[lastStart] = marker.Position; } else { MessageBox.Show("Invalid Marker: \"" + marker.Label + "\" detected at timecode: " + marker.Position.ToString()); vegas.Transport.CursorPosition = marker.Position; return; } } foreach (KeyValuePair<Timecode, Timecode> kvp in timecodes) { foreach (Track track in vegas.Project.Tracks) { foreach (TrackEvent trackEvent in track.Events) { if ((trackEvent.Start < kvp.Key) && ((trackEvent.Start + trackEvent.Length) > kvp.Key)) { var newLength = kvp.Key - trackEvent.Start; trackEvent.Split(newLength); track.Events.Remove(trackEvent); } } } foreach (Track track in vegas.Project.Tracks) { foreach (TrackEvent trackEvent in track.Events) { if ((trackEvent.Start < kvp.Value) && ((trackEvent.Start + trackEvent.Length) > kvp.Value)) { var newLength = kvp.Value - trackEvent.Start; trackEvent.Split(newLength); } } } } foreach (Track track in vegas.Project.Tracks) { if (track.Events.Count > 0) { TrackEvent lastEvent = track.Events[track.Events.Count - 1]; track.Events.Remove(lastEvent); } } /*foreach (Track track in vegas.Project.Tracks) { Timecode tracktime = new Timecode(0); foreach (TrackEvent trackEvent in track.Events) { trackEvent.Start = tracktime; trackEvent.End = tracktime + trackEvent.Length; tracktime = trackEvent.End; } }*/ /*vegas.Project.Markers.Clear();*/ } }
However, the problem with it is trying to close the gaps that the Split makes.
Currently, if the entire track had footage/audio, it works fine when it goes to iterate through all the tracks and collapse them. However, if there was a track above it that had a sound effect there, the script will try to collapse the entire amount of whitespace between 0:00:00 and where the sound effect starts, basically shoving it all the way to the left.
Is there a way to just make it split the tracks, collapse all the whitespace and preserve where the track was?