How to add CDMarker

johnmeyer wrote on 2/14/2006, 9:07 AM
I was going to help someone by modifying Ed's Add Markers to Events script to instead add CD markers. The CD Markers are a subclass, and since I don't write scripts often, I'm making some sort of rookie mistake. Here's the code, adapted from Ed's script. I just changed the two lines where the marker is assigned, and also tried to let jscript take care of the variable typing.

Any help would be appreciated.

===========
try {
var zeroMark : Timecode = new Timecode(0);

//Find the selected event
var track = FindSelectedTrack();
if (null == track)
throw "no selected track";

var eventEnum = new Enumerator(track.Events);
while (!eventEnum.atEnd()) {
var evnt : TrackEvent = TrackEvent(eventEnum.item());

if (evnt.Start > zeroMark) {
//Put a marker at the start point

var myMarker = new CDMarker(evnt.Start); // <---- These two lines!
Vegas.Project.Markers.Add(myMarker); //
// Vegas.Project.CDTracks.Add(myMarker); // This doesn't work either
// Vegas.Project.Markers.CDTracks.Add(myMarker); // Nor does this
}

eventEnum.moveNext();
}


Comments

jetdv wrote on 2/14/2006, 12:17 PM
John, change the "if" statement to >= if you want to include an event at the beginning of the timeline. Then make these changes:


if (evnt.Start >= zeroMark) {
//Put a marker at the start point
var myMarker = new CDRegion(evnt.Start, evnt.Length); // <---- These two lines!
Vegas.Project.CDTracks.Add(myMarker);
johnmeyer wrote on 2/14/2006, 6:00 PM
Thanks Ed. I guess I had brain freeze when I failed to realize that the CD "markers" are really regions. There is a CDMarker class in the API. I don't know what that refers to, but that's what I was trying to set.

This works just as I had hoped.