This is a variation of my other script, based on a request from a user. This script will lock or un-lock all events on all selected tracks. The decision on whether to lock or un-lock is made based on the lock status of the first event. So, if the first event on the first selected track is un-locked, the script will un-lock ALL events on ALL selected tracks. If that first event is locked, then all events on all selected tracks are locked.
[Edit] Look further down in this thread for a better version of this script.
[Edit] Look further down in this thread for a better version of this script.
/**
* PURPOSE OF THIS SCRIPT:
*
* Locks or unlocks all events on selected track, based on the lock status
* of the first event on the first selected track.
*
* Copyright © John Meyer 2004
* Written: September 23, 2004
*
**/
import System;
import System.IO;
import System.Windows.Forms;
import Sony.Vegas;
try {
var first_time = true;
//Go through the list of Tracks
var trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());
var eventEnum = new Enumerator(track.Events);
var evnt : TrackEvent = TrackEvent(eventEnum.item());
if (track.Selected) {
if (first_time) {
var lockedevnt = false;
if (evnt.Locked == true) {
lockedevnt = true;
}
first_time = false;
}
//Go through the list of Events
while (!eventEnum.atEnd()) {
evnt = TrackEvent(eventEnum.item());
if (lockedevnt) {
evnt.Locked = true;
}
else {
evnt.Locked = false;
}
eventEnum.moveNext();
} // End While eventEnum
} // End if track selected
trackEnum.moveNext();
} // End While trackEnum
if (lockedevnt) {
MessageBox.Show("Events on selected tracks are all locked.","Completed",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else {
MessageBox.Show("Events on selected tracks are all UN-locked.","Completed",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
eventEnum.moveNext();
} catch (e) {
MessageBox.Show(e);
}