Adding markers at regular intervals always seemed dumb. Who wants a chapter stop in the middle of a scene? So, I modified an existing script by Ed so that you get markers at more-or-less regular intervals, but only at the beginning of events on the selected track. Probably useful to about two people in the universe, but it was easy to do.
[Edited to improve consistency of where markers get placed. -Feb 3, 2007]
                        
                    
                    
                            [Edited to improve consistency of where markers get placed. -Feb 3, 2007]
/**
* This script will add markers at regular intervals,
* but only at events on the selected track, and only at
* event boundaries.
*
* Based on a script by: Edward Troxel
* Written by John Meyer February 1, 2007
**/
import System;
import System.IO;
import System.Windows.Forms;
import Sony.Vegas;
//Change this value to be the desired interval
//Format: hh:mm:ss:ff (hours:minutes:seconds:frames)
var Interval = "00:00:55:00";
try {
var myMarker : Marker;
var IncTime : Timecode = new Timecode(Interval);
var CurrTime : Timecode = IncTime;
//Find the selected event
var track = FindSelectedTrack();
if (null == track)
throw "no selected track";
for (var evnt in track.Events) {
if ( CurrTime <= evnt.Start ){
//Put a marker at the start point
if ( !MarkerExist(evnt.Start.ToMilliseconds()) ) {
myMarker = new Marker(evnt.Start);
Vegas.Project.Markers.Add(myMarker);
}
CurrTime = evnt.Start + IncTime;
} // End if CurrTime
} // End for var evnt
} catch (e) {
MessageBox.Show(e);
}
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;
}