Comments

johnmeyer wrote on 11/1/2010, 3:42 PM
Yes it could. I'd do it, but after doing a custom script for "Sebaz" and then finding that he only complained about it, even though the script will work perfectly if he just takes the time to change the extension to "js"

So, unfortunately, I'm not doing any more custom scripts.

However, you will find scripts I have done in the past, and if you have any programming experience, all you have to do is take a script I wrote which selects the event under the cursor and simultaneously deslects all other events, and then combine it with another script I wrote which selects all events that come from the same media as the first selected event on the timeline. That should give you what you want: every event that comes from that same media is now selected. The script that selects all the media only selects events after the current event, so you'll need to remove the:

if (evnt.Start.ToMilliseconds() >= dStart)

statement so that all events on the selected timeline are selected. Actually, if you make that change, you can use the two scripts as is, assign them to two different keys, and get what you want with two keystrokes instead of one. So, you are 98% of the way towards a single-keystroke solution.

/** 
* PURPOSE OF THIS SCRIPT:
*
* Select event at cursor, and de-select all other events.
*
* A video track must be selected. If an audio track is selected, nothing happens.
* If the track beneath the video track contains audio, the audio event in that track
* that lies beneath the cursor will also be selected.
*
* Copyright © John Meyer 2004
* Written: September 23, 2004
*
**/

import System;
import System.IO;
import System.Windows.Forms;
import Sony.Vegas;


try {

//Global declarations
var dStart : Double;
var dLength : Double;
var dCursor : Double;
var trackEnum : Enumerator;
var evnt : TrackEvent;
var CurrentEvnt : TrackEvent;

var track = FindSelectedTrack(); // Use this function to find the first selected track.
var eventEnum = new Enumerator(track.Events);

if (track.IsVideo()) { // Proceed only if selected track is video track.

if ( SelectEventAtCursor() ) { // Function that selects events under cursor.

// Get set to look at track directly below the video track.
trackEnum.moveNext(); // Go to next track.

if (!trackEnum.atEnd()) { // Only proceed if there is a track below the video track.
track = Track(trackEnum.item()); // When doing the first track (above), these two lines were executed
eventEnum = new Enumerator(track.Events); // in the FindSelectedTrack() function.
if (track.IsAudio()) { // Only trim the event if this is an audio track.
SelectEventAtCursor();
}
}
}
}
// Vegas.Cursor = CurrentEvnt.Start; // Enable this line to move cursor to start of selected event.
Vegas.UpdateUI();

} catch (e) {
MessageBox.Show(e);
}

// End of main program



// Beginning of functions

function FindSelectedTrack() : Track {
trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());

if (track.Selected) {
return track;
}
trackEnum.moveNext();
}
return null;
}


/**
*
* The following function finds the event on the selected track
* that lies under the cursor. It also deselects all other events.
*
**/

function SelectEventAtCursor() {

var EventFound : boolean = false; // Function returns false if no video media under cursor.

dCursor = Vegas.Cursor.ToMilliseconds(); // Remember the cursor position.

//Go through each event on the track.

while (!eventEnum.atEnd()) {
evnt = TrackEvent(eventEnum.item());
evnt.Selected = false; // De-select the event

// Get the event's start and length timecode, in milliseconds.
dStart = evnt.Start.ToMilliseconds();
dLength = evnt.Length.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; // Select this event.
EventFound = true;
CurrentEvnt = evnt;
}
eventEnum.moveNext(); // Go to next event on this timeline.

}
return EventFound;
}


/** 
* This script selects all events that match the media on the
* first selected event on the first selected timeline.
* It only affects events AFTER the selected event.
*
* Copyright 2008 - John H. Meyer
* Last revision, May 4, 2008
*
**/

import System;
import System.Collections;
import System.Text;
import System.IO;
import System.Drawing;
import System.Windows.Forms;
import Sony.Vegas;

var evnt : TrackEvent;

try {
//Find the selected event
var track = FindSelectedTrack();
if (null == track) // Must select a track
throw "no selected track";
var eventEnum = new Enumerator(track.Events);
if (track.IsVideo()) { // Track must be a video track
while (!eventEnum.atEnd()) { // Find selected event
evnt = TrackEvent(eventEnum.item());
if (evnt.Selected) {
var selectedevnt = VideoEvent(evnt);
var media = Vegas.Project.MediaPool.Find (evnt.ActiveTake.MediaPath);
var dStart = evnt.Start.ToMilliseconds();
break; // Found first selected event on timeline, so quit looking on timeline.
} //End if
eventEnum.moveNext();
} // End while eventEnum

eventEnum = new Enumerator(track.Events);

while (!eventEnum.atEnd()) { // Find selected event
evnt = TrackEvent(eventEnum.item());

var vevnt = VideoEvent(evnt);
// Actually make the change to set the keyframe to SD cropping
if (media == Vegas.Project.MediaPool.Find (evnt.ActiveTake.MediaPath) ) {
if (evnt.Start.ToMilliseconds() >= dStart) {
evnt.Selected = true;
}
}
eventEnum.moveNext();
} // End While eventEnum
} // End If track.IsVideo

else {
MessageBox.Show("You must select a video track");
}


} 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;
}



JohnnyRoy wrote on 11/1/2010, 7:52 PM
> When I'm multicamera editing, I do this often: right-click on a clip on the timeline to "Select in Project Media List", then right-click on the found media in the Project Media List to "Select Timeline Events". Can a process like this possibly be turned into a script?

VASST Ultimate S Pro has had this for years now. On the Editing Tools tab there is a function to select all sorts of events and one option is to Select Same Source. All the events that share the same source file as the selected event will be selected.

~jr
cold-ones wrote on 11/3/2010, 10:29 AM
Thank you, John & Johnny!

I appreciate the expertise that you share with the rest of us! I often hit snags in the thick of a project and wish I had the skills to whip up a script to fix them. Sometimes I'm able to hack up an existing script and make it do what I want, I'll certainly try in this case. I'll also check into Ultimate S.

I know I speak for many when I say that your advice and generosity of spirit is greatly appreciated (although I am reminded of the words of George Sand: "Charity degrades those who receive it and hardens those who dispense it.”)

Let's hope that's untrue, for all of our sakes.