Need Script Help

MichaelS wrote on 7/5/2004, 7:10 PM
I need to find a script that will do the following in one action:

1. Apply a cut at a point I select.

2. Apply a fade on both sides of that cut.

3. Apply a marker at the cut.

4. Applying these actions to all video and audio tracks would also be great.

This is for Vegas 4.

I would think it would be simple, but my understanding of scripting
is very limited.

Your help is appreciated. Thanks.

Comments

JohnnyRoy wrote on 7/9/2004, 10:07 AM
Mike,

Here is the script you asked for. Adjust the fade amount (fadeAmount) to whatever length you want. Enjoy:
/** 
* Program: SplitFadeMarkEventsAtCursor.js
* Description: This script will:
* 1. Apply a cut at the cursor position.
* 2. Apply a fade on both sides of that cut.
* 3. Apply a marker at the cut.
* 4. Apply these actions to all video and audio tracks.
*
* Author: Johnny (Roy) Rofrano john_rofrano at hotmail dot com
*
* Last Updated: 2004-Jul-09 Initial release
*
**/
import System.Windows.Forms;
// If you have Vegas 4 use following import otherwise comment is out with "//"
import SonicFoundry.Vegas;
// If you have Vegas 5 use following import otherwise comment is out with "//"
//import Sony.Vegas;
// fade amount for split events
var fadeAmount : Timecode = new Timecode("00:00:01.00");
try
{
// Add a marker at the point we are going to split
var marker = new Marker(Vegas.Cursor);
Vegas.Project.Markers.Add(marker);
   // Iterate through all video tracks
for (var track in Vegas.Project.Tracks)
{
var eventEnum = new Enumerator(track.Events);
while (!eventEnum.atEnd())
{
var evnt = eventEnum.item();
// note: vegas 4 does not have event.End but Vegas 5 does
var evntEnd : Timecode = evnt.Start + evnt.Length;
if (evnt.Start < Vegas.Cursor && evntEnd > Vegas.Cursor)
{
// Split the event
var splitOffset : Timecode = Vegas.Cursor - evnt.Start;
evnt.Split(splitOffset);
            // Add a fade out to this event
evnt.FadeOut.Length = fadeAmount;
            // Add a fade in to the next event
eventEnum.moveNext();
evnt = eventEnum.item();
evnt.FadeIn.Length = fadeAmount;
            // No need to keep iterrating on this track
break;
}
eventEnum.moveNext();
}
}
}
catch (errorMsg)
{
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
/*** END OF SCRIPT ***/

EDIT: Modified to include both SonicFoundry and Sony imports. You must use only one of them. Note: The script was written for Vegas 4 by request.

~jr
johnmeyer wrote on 7/9/2004, 12:37 PM
JohnnyRoy,

Thanks! I was needing something like this (minus the markers) just the other day. I'll take out the markers and use it.
MichaelS wrote on 7/9/2004, 7:34 PM
This is exactly what makes Vegas forum users so incredible. I have several projects that I do each week which contains about 30 to 50 of these actions. This script will save me hours of work. I hope other users find it useful as well.

Thank you.

MichaelS
ricklaut wrote on 7/10/2004, 9:51 AM
I too have use for this one. Very cool... I'm getting an error though (and don't know much about scripting, so this is probably a no brainer...

The error is: Compilation error on line 17:

Variable 'Timecode' has not been declared


System.ApplicationException: Failed to compile script: 'C:\Program Files\Sony\Vegas 5.0\Script Menu\Complete Converted Script Download\SplitFadeMarkEventsAtCursor.js'
at Sony.Vegas.ScriptHost.RunScript()

Line 17 looks like this: var fadeAmount : Timecode = new Timecode("00:00:01.00");

What do I need to change?

Rick
MichaelS wrote on 7/10/2004, 10:16 AM
It works fine on my machine. What version of Vegas are you using? I requested that it be written for V4. Could this be an issue?
jetdv wrote on 7/10/2004, 11:06 AM
For Vegas 4, the "import" line should read:

import SonicFoundry.Vegas;


For Vegas 5, the "import" line should read:

import Sony.Vegas;



Make sure it reads correctly for the version of Vegas you have.
JohnnyRoy wrote on 7/10/2004, 1:27 PM
Sorry, I should have put both in the script. Mike specifically asked for a Vegas 4 script so that’s why I posted it that way. I’ve modified the post to include the Vegas 5 import if you need it.

~jr
ricklaut wrote on 7/11/2004, 6:37 AM
Doh! Didn't even look at that.... (caused by my penchant for not reading the manual I guess).

I'm using 5.0b, so I changed it to Sony and it works great!

Thanks!

Rick