I'm still working on a script to delete "n" frames from the beginning of events captured from analog video. Edward Troxel gave me enough code to get started, and I've just about finished the project. During the process, I developed a fragment that might be useful to others, namely the ability to select all events that are touching the cursor. If the cursor lands on the boundary between two adjacent events, it selects the event to the right. If two events overlap under the curso, it selects them both. All other events that do not touch the cursor are un-selected.
Here it is:
Here it is:
/**
* This script selects all events under the cursor.
* Written by: John Meyer
* With thanks to: Edward Troxel
* Last updated: 06-02-2003
**/
import System;
import System.IO;
import System.Windows.Forms;
import SonicFoundry.Vegas;
try {
//Go through the list of Tracks
var trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());
//Go through the list of Events
var eventEnum = new Enumerator(track.Events);
while (!eventEnum.atEnd()) {
var evnt : TrackEvent = TrackEvent(eventEnum.item());
evnt.Selected = false; // De-select the event
//Get the timecode for the beginning and end of the event
//Also get the timecode for the cursor position
var dStart : Double = evnt.Start.ToMilliseconds();
var dLength : Double = evnt.Length.ToMilliseconds();
var dCursor : Double = Vegas.Cursor.ToMilliseconds();
//If the cursor timecode is between the beginning and end of the
//event timecodes, then select the event.
if ( (dCursor >= dStart) && ( dCursor < (dLength + dStart) ) )
evnt.Selected = true;
eventEnum.moveNext();
}
trackEnum.moveNext();
}
} catch (e) {
MessageBox.Show(e);
}