I had a request for a script that would put markers at every event that had a transition. This is a simpleminded way to do this. The script looks at events on the selected timeline and puts a marker wherever an event overlaps the previous event. It makes no attempt to look at transitions created by events on different tracks. I have also uploaded the script to Sundance to make it easier for people to download and use.
This is no thing of beauty, but hopefully it will help the people that requested it:.
[Edit] You can now download this file here:
Markers at Event Overlap Script
This is no thing of beauty, but hopefully it will help the people that requested it:.
[Edit] You can now download this file here:
Markers at Event Overlap Script
/**
* This script adds markers at transitions on the first selected track.
* The markers are labeled as "Chapter 0, Chapter 1, etc.
* If a marker already exists, no new marker is created.
* If you add a transition and re-run the script without deleting all previous chapter markers,
* however, the new chapter number will start with "Chapter 0" (i.e., you will
* end up with duplicate chapter names). Why? Because I am lazy.
*
* Written By: John Meyer
* 5/25/2004
*
* Requires Vegas 5.0 (change line below to make it work with Vegas 4.0c or above)
**/
import System;
import System.IO;
import System.Windows.Forms;
import Microsoft.Win32;
import Sony.Vegas; // Replace this line with the one below for Vegas 4.0c, 4.0d, or 4.0e.
//import SonicFoundry.Vegas;
var dStart : Double;
var dLength : Double;
var dPrev_Start : Double;
var dPrev_Length : Double;
var count: Double;
try {
var myMarker : Marker;
//Find the first selected track
var track = FindSelectedTrack();
if (null == track)
throw "no selected track";
var eventEnum = new Enumerator(track.Events);
var prev_evnt : TrackEvent = TrackEvent(eventEnum.item());
count = 0;
// Cycle through all events on the selected track
while (!eventEnum.atEnd()) {
var evnt : TrackEvent = TrackEvent(eventEnum.item());
dPrev_Start = prev_evnt.Start.ToMilliseconds();
dPrev_Length = prev_evnt.Length.ToMilliseconds();
dStart = evnt.Start.ToMilliseconds();
dLength = evnt.Length.ToMilliseconds();
// Only add marker if this event overlaps, and if no marker already exists.
if ( ( dStart < dPrev_Start + dPrev_Length ) && (!MarkerExist(evnt.Start.ToMilliseconds() ) ) ) {
myMarker = new Marker(evnt.Start);
Vegas.Project.Markers.Add(myMarker);
myMarker.Label = "Chapter " + count.ToString();
count++;
}
// Prepare for next event
eventEnum.moveNext();
prev_evnt = evnt;
}
} catch (e) {
MessageBox.Show(e);
}
// Function to find first selected track
function FindSelectedTrack() : Track {
var trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());
if (track.Selected) {
return track;
}
trackEnum.moveNext();
}
return null;
}
// Function to check if there is a marker at timecode passed to this function
// Timecode (dStart) must be in milliseconds
function MarkerExist (dStart) : boolean {
var fmarkerEnum = new Enumerator(Vegas.Project.Markers);
while (!fmarkerEnum.atEnd()) {
var fMyMarker = fmarkerEnum.item();
var fMarkerStart = fMyMarker.Position.ToMilliseconds();
if ( dStart == fMarkerStart ) {
return 1;
}
fmarkerEnum.moveNext();
} // End while fmarkerEnum
return 0;
}