| View previous topic :: View next topic |
| Author |
Message |
Edward Troxel Site Admin
Joined: 14 Jul 2004 Posts: 5103
|
Posted: Tue Aug 03, 2004 6:38 pm Post subject: Vol #1, Issue #1 (March 2003) |
|
|
The premiere issue of Vegas Tips, Tricks, and Scripts.
In this issue:
What is Tips, Tricks, and Scripts
Vegas Preferences - Part 1
What is Scripting
Fade the Selected Event In and Out
Download Vol. 1, Issue 1
Last edited by Edward Troxel on Sun Mar 15, 2009 12:51 pm; edited 1 time in total |
|
| Back to top |
|
 |
dturnidge
Joined: 11 Feb 2006 Posts: 2
|
Posted: Sun Feb 12, 2006 12:59 am Post subject: |
|
|
I downloaded and printed all your newsletters and started reading. I typed in your fadeinfadeout javascript, and had the following error:
Compilation error on line 25:
Variable 'TrackEvent' has not been declared
System.ApplicationException: Failed to compile script: 'C:\Program Files\Sony\Vegas 6.0\Script Menu\FadeInFadeOut.js'
at Sony.Vegas.VSAManager.Compile()
at Sony.Vegas.ScriptHost.RunScript(Boolean fCompileOnly)
This is what I entered:
/**
* This script will add a one second fade in and fade out on the selected event
* Written by: Edward Troxel
* Revised: 02/26/2003
**/
import System.Windows.Forms;
import SonicFoundry.Vegas;
try {
// Find the selected event
var evnt = FindSelectedEvent();
if (null == evnt)
throw "no selected event";
// Now set the one second fade in and fade out
evnt.FadeIn.Length = new Timecode(1000);
evnt.FadeOut.Length = new Timecode(1000);
} catch (e) {
MessageBox.Show(e);
}
function FindSelectedEvent() : TrackEvent {
var trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());
var eventEnum = new Enumerator(track.Events);
while (!eventEnum.atEnd()) {
var evnt : TrackEvent = TrackEvent(eventEnum.item());
if (evnt.Selected) {
return evnt;
}
eventEnum.moveNext();
}
trackEnum.moveNext();
}
return null;
}
I have worked very sparingly with JS, so it is very likely that I entered something wrong. Please let me know what you see...
Thanks,
Dave |
|
| Back to top |
|
 |
Edward Troxel Site Admin
Joined: 14 Jul 2004 Posts: 5103
|
Posted: Sun Feb 12, 2006 1:28 am Post subject: |
|
|
That's an easy one. That article was written on Vegas 4. Sony purchased Vegas while Vegas 4 was current and the following change is required for Vegas 5 or Vegas 6. Try making this change:
Find:
import SonicFoundry.Vegas;
and change it to:
import Sony.Vegas;
After making the above change, all should work as expected. |
|
| Back to top |
|
 |
dturnidge
Joined: 11 Feb 2006 Posts: 2
|
Posted: Sun Feb 12, 2006 1:54 am Post subject: |
|
|
Cool! It worked! Hopefully, before I get done with your "book" I'll be able to write the one I need!!
Dave |
|
| Back to top |
|
 |
Rekcin
Joined: 04 Dec 2006 Posts: 3 Location: Nashville, TN
|
Posted: Tue Dec 05, 2006 3:35 pm Post subject: Changes |
|
|
Is there an easy way to make this work on all selected events? _________________ Doh! |
|
| Back to top |
|
 |
Edward Troxel Site Admin
Joined: 14 Jul 2004 Posts: 5103
|
Posted: Tue Dec 05, 2006 6:22 pm Post subject: |
|
|
Yes there is. The Fade tool in Excalibur does this.
Here's an untested quickie:
| Code: | import System.Windows.Forms;
import Sony.Vegas;
try {
var trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());
var eventEnum = new Enumerator(track.Events);
while (!eventEnum.atEnd()) {
var evnt : TrackEvent = TrackEvent(eventEnum.item());
if (evnt.Selected) {
// Now set the one second fade in and fade out
evnt.FadeIn.Length = new Timecode(1000);
evnt.FadeOut.Length = new Timecode(1000);
}
eventEnum.moveNext();
}
trackEnum.moveNext();
}
} catch (e) {
MessageBox.Show(e);
}
|
|
|
| Back to top |
|
 |
Rekcin
Joined: 04 Dec 2006 Posts: 3 Location: Nashville, TN
|
Posted: Tue Dec 05, 2006 6:50 pm Post subject: Awesome! |
|
|
Your untested quickie works like a charm, and saved me hours of manual work. Thank you so much.  _________________ Doh! |
|
| Back to top |
|
 |
|