Looking for a script to drag event handles

Sebaz wrote on 12/11/2008, 4:07 PM
I need a time saving script for something I do quite often. The cursor is between two events and I drag the handles for opacity and gain 10, 15 or 30 frames to each side of the cursor to create a kind of fade through black, but I like the opacity change better than the fade through black transition, it looks better to me.

Is there a script that does that, just drag the four envelope handles to the number of frames specified in the script. If it doesn't exist, how difficult would be to create one?

Comments

Sebaz wrote on 12/12/2008, 5:21 PM
Excellent!!!! Forever thankful.
Sebaz wrote on 12/13/2008, 6:31 AM
While this script is almost what I was looking for, and a great time saver, I still would like to find one that I can put the cursor exactly between two events and it will drag the audio and video handles one second in each direction, or 15 frames if I want it to, probably a second script for that.

What software is used to create and edit these scripts? Maybe I can try to modify this one to make it work exactly like I need.
Rosebud wrote on 12/13/2008, 8:53 AM

/* fade adjacent events.cs for Vegas Pro 8
* author: Gilles Pialat
* Updated: December 13, 2008
*
* Select video & audio tracks and place cursor between two events
* before to run this script
*/

using System;
using Sony.Vegas;

public class EntryPoint
{
public void FromVegas(Vegas myVegas)
{
Timecode fadeLength = Timecode.FromFrames(15); // length of the fades in frames
CurveType curveType;

// Curve Type
curveType = CurveType.Smooth;
//curveType = CurveType.Fast;
//curveType = CurveType.Linear;
//curveType = CurveType.Sharp;
//curveType = CurveType.None;
//curveType = CurveType.Slow;

Timecode cursorPosition = myVegas.Transport.CursorPosition;

foreach (Track track in myVegas.Project.Tracks)
{
if (track.Selected & track.Events.Count > 1)
{
for (int index = 1; index < track.Events.Count; index++)
{
if ((cursorPosition == track.Events[index].Start) & (cursorPosition == track.Events[index - 1].End))
{
track.Events[index].FadeIn.Length = fadeLength;
track.Events[index].FadeIn.Curve = curveType;
track.Events[index - 1].FadeOut.Length = fadeLength;
track.Events[index - 1].FadeOut.Curve = curveType;
break;
}
}
}
}
}
}
Sebaz wrote on 12/13/2008, 2:34 PM
Thank you. Basically I have to copy this onto Notepad and save it with a .js extension, right? I wonder if I did something wrong because when I put the cursor between the two events and I run the script I get this error:

C:\Program Files\Sony\Vegas Pro 8.1\Script Menu\15 frame AV handles.js(9) : Syntax error. Write 'var identifier : Type' rather than 'Type identifier' to declare a typed variable
C:\Program Files\Sony\Vegas Pro 8.1\Script Menu\15 frame AV handles.js(10) : The list of attributes does not apply to the current context
C:\Program Files\Sony\Vegas Pro 8.1\Script Menu\15 frame AV handles.js(14) : Expected ',' or ')'
C:\Program Files\Sony\Vegas Pro 8.1\Script Menu\15 frame AV handles.js(14) : Syntax error. Write 'function identifier(...) : Type{' rather than 'Type identifier(...){' to declare a typed function
C:\Program Files\Sony\Vegas Pro 8.1\Script Menu\15 frame AV handles.js(16) : The list of attributes does not apply to the current context
C:\Program Files\Sony\Vegas Pro 8.1\Script Menu\15 frame AV handles.js(17) : Syntax error. Write 'var identifier : Type' rather than 'Type identifier' to declare a typed variable
C:\Program Files\Sony\Vegas Pro 8.1\Script Menu\15 frame AV handles.js(27) : The list of attributes does not apply to the current context
C:\Program Files\Sony\Vegas Pro 8.1\Script Menu\15 frame AV handles.js(29) : Expected ',' or ')'
C:\Program Files\Sony\Vegas Pro 8.1\Script Menu\15 frame AV handles.js(29) : Expected ';'
C:\Program Files\Sony\Vegas Pro 8.1\Script Menu\15 frame AV handles.js(33) : Expected ';'
C:\Program Files\Sony\Vegas Pro 8.1\Script Menu\15 frame AV handles.js(33) : Expected ')'
C:\Program Files\Sony\Vegas Pro 8.1\Script Menu\15 frame AV handles.js(33) : Expected ';'
C:\Program Files\Sony\Vegas Pro 8.1\Script Menu\15 frame AV handles.js(41) : Can't have 'break' outside of loop
C:\Program Files\Sony\Vegas Pro 8.1\Script Menu\15 frame AV handles.js(9) : Variable 'using System;' has not been declared
C:\Program Files\Sony\Vegas Pro 8.1\Script Menu\15 frame AV handles.js(10) : Variable 'using Sony.Vegas;' has not been declared
Rosebud wrote on 12/13/2008, 3:10 PM
It's CS script as mentioned in the header.
Sebaz wrote on 12/13/2008, 4:27 PM
Oh, right, I had totally missed that. Now, what if I wanted to apple this script but without having to expressly select both the audio and video tracks? Can it be modified so that it will drag the handles on the first audio and video tracks regardless of what's selected? I would think it's in these lines but I wouldn't know what to modify, probably because I'm too tired to think straight.

foreach (Track track in myVegas.Project.Tracks)
{
if (track.Selected & track.Events.Count > 1)
{
for (int index = 1; index < track.Events.Count; index++)
{
if ((cursorPosition == track.Events[index].Start) & (cursorPosition == track.Events[index - 1].End))
Rosebud wrote on 12/13/2008, 10:36 PM
Remove the « track.selected » test. (so new code is):
if (track.Events.Count > 1)


But all tracks in your project will be processed.
Sebaz wrote on 12/14/2008, 9:06 AM
Works perfect! You should upload this to Vaast, it's very useful.
Rosebud wrote on 12/14/2008, 11:57 AM
I added it to my site.
Sebaz wrote on 12/14/2008, 2:41 PM
I'll check that collection as soon as I get a chance.